DoCmd Object.
The SetMenuItem method carries out the SetMenuItem action in Visual Basic. For more information on how the action and its arguments work, see the action topic.
DoCmd.SetMenuItem menuindex [, commandindex] [, subcommandindex] [,flag]
The SetMenuItem method uses the following arguments.
Argument |
Description |
menuindex |
An integer, counting from 0, that is the valid index of a menu on the custom menu bar or global menu bar for the active window, as defined in the menu bar macro for the custom menu bar or global menu bar. If you select a menu with this argument and leave the commandindex and subcommandindex arguments blank (or set them to -1), you can enable or disable the menu name itself. You can’t, however, check or uncheck a menu name (Microsoft Access ignores the acMenuCheck and acMenuUncheck settings for the flag argument for menu names). |
commandindex |
An integer, counting from 0, that is the valid index of a command on the menu selected with the menuindex argument, as defined in the macro group that defines the selected menu for the custom menu bar or global menu bar for the active window. |
subcommandindex |
An integer, counting from 0, that is the valid index of a subcommand in the submenu selected with the commandindex argument, as defined in the macro group that defines the selected submenu for the custom menu bar or global menu bar for the active window. |
flag |
One of the following intrinsic constants: acMenuUngray If you leave this argument blank, the default (acMenuUngray) is assumed. |
You can leave an optional argument blank in the middle of the syntax, but you must include the argument’s comma. If you leave a trailing argument blank, don’t use a comma following the last argument you specify.
AddMenu Action, DoCmd Object, DoMenuItem Method, MenuBar Property, SetMenuItem Action.
This example uses the SetMenuItem method to disable the second command in the first menu on the custom menu bar for the active window.
DoCmd.SetMenuItem 0, 1, , acMenuGray