Enabled Property

Applies To

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

Description

True if the specified command bar or command bar control is enabled. Read/write Boolean.

Remarks

For command bars, setting this property to True causes the name of the command bar to appear in the list of available command bars.

For built-in controls, if you set the Enabled property to True the application determines its state but setting it to False will force it to be disabled.

Specifics (Microsoft Access)

You can use this property to disable (dimmed) or enable a menu item or command button. This property applies to menu names, submenu names, and items on submenus. The Enabled property replaces the functionality supplied by the SetMenuItem action and SetMenuItem method in Microsoft Access 95.

You can disable a menu item that Microsoft Access would normally enable, but you can't enable a menu item that Microsoft Access would normally disable.

Example

This example adjusts the command bars according to the user level specified by user. If user is "Level 1," the command bar named "VB Custom Bar" is displayed. If user is any other value, the built-in command bar "Visual Basic" is reset to its default state and the command bar named "VB Custom Bar" is disabled.

Set myBar = CommandBars("VB Custom Bar")
If user = "Level 1" Then
    myBar.Visible = True
Else
    CommandBars("Visual Basic").Reset
    myBar.Enabled = False
End If
This example adds two command bar buttons to the command bar represented by the variable myBar. The first control is disabled and will appear grey. The second control is enabled by default.

With myBar
    .Controls.Add Type:=msoControlButton, Id:=3
    .Controls(1).Enabled = False
    .Controls.Add Type:=msoControlButton, Id:=3
End With
myBar.Visible = True