Id Property

Applies To

CommandBarButton object, CommandBarComboBox object, CommandBarControl object, CommandBarPopup object.

Description

Returns the ID for the specified built-in command bar control. Read-only Long.

Remarks

A control's ID determines the built-in action for that control. The value of the Id property for all custom controls is 1.

See Also

FindControl method.

Specifics (Microsoft Access)

The Id property can only be set when you create a new control. Set the Id argument of the Add method of the CommandBarControls collection to an Integer value that corresponds to a built-in command button or menu item, or to one of the equivalent intrinsic constants used with the RunCommand method in Microsoft Access. For a custom control, set the Id argument to 1 or leave it blank.

You can use the Id property to determine the Integer value corresponding to a built-in control. For example, to determine the Integer value corresponding to the Paste command on the Edit menu of the main menu bar, use the following reference:

CommandBars("Menu Bar").Controls("Edit").Controls("Paste").Id
Example

This example changes the button face of the first control on the command bar named "Custom2" if the button's ID value is less than 25.

Set ctrl = CommandBars("Custom2").Controls(1)
With ctrl
    If .Id < 25 Then
        .FaceId = 17
        .Tag = "Changed control"
    End If
End With
The following example changes the caption of every control on the toolbar named "Standard" to the current value of the Id property for that control.

For Each ctl In CommandBars("Standard").Controls
    ctl.Caption = CStr(ctl.Id)
Next ctl