You can use the AddMenu action to create:
Note While you can still create all these types of custom menus by using macros containing AddMenu actions in Microsoft Access 98 (and any existing custom menus you've created by using macros will still work), it's recommended that you create them by using the Customize dialog box, available by pointing to Toolbars on the View menu and clicking Customize. While the Customize dialog box is displayed, you can easily create a new menu or customize a built-in menu.
Setting
The AddMenu action has the following arguments.
Action argument | Description |
---|---|
Menu Name | The name of the drop-down menu to add to the custom menu bar or global menu bar. Enter the menu name in the Menu Name box in the Action Arguments section of the Macro window. This is a required argument for custom menu bars and global menu bars. This argument is ignored for custom shortcut menus and global shortcut menus. |
To create an access key so that you can use the keyboard to choose the menu, type an ampersand (&) before the letter you want to be the access key. This letter will be underlined in the menu name on the menu bar. | |
Menu Macro Name | The name of the macro group that contains the macros for the menu's commands. This is a required argument.
If you run a macro containing the AddMenu action in a library database, Microsoft Access looks for the macro group with this name in the current database only. |
Status Bar Text | The text to display in the status bar when the menu is selected. This argument is ignored for custom shortcut menus and global shortcut menus. |
Remarks
To create a custom menu bar, a custom shortcut menu, a global menu bar, or a global shortcut menu by using macros, you must do the following:
Each menu on the menu bar requires a separate AddMenu action.
The custom and global menu bars and shortcut menus replace the built-in menu bars and shortcut menus for the objects they're attached to. If you want to retain certain Microsoft Access commands to use on these menus, use the RunCommand action to put the commands into the macro groups for the desired menus.
You can run a macro from a menu command by using the RunMacro action in the macro for the command.
Note AddMenu actions can be used only in a menu bar macro specified by the MenuBar or ShortcutMenuBar property of a form, form control, or report, or by the Menu Bar box or Shortcut Menu Bar box in the Startup dialog box, available by clicking Startup on the Tools menu. Menu bar macros should contain only AddMenu actions.
When you specify a menu bar macro for a form or report or for the database, Microsoft Access runs this menu bar macro whenever the form, report, or database is opened. If you make changes to the menu bar macro or the macro groups that define the commands on the drop-down menus while the form, report, or database is open, you must close the form, report, or database and reopen it to see the changes in the custom menu bar and its menus.
When you are creating the macro groups that contain the commands for a custom menu, the following information applies:
You can create a submenu for a custom menu or a custom shortcut menu by using the AddMenu action in a macro group specified by the Menu Macro Name argument. If you put an AddMenu action in such a macro group, Microsoft Access creates a submenu with the menu name and status bar text specified by the Menu Name and Status Bar Text arguments for this AddMenu action. The submenu contains the commands defined by the macros in the macro group specified by the Menu Macro Name argument for the AddMenu action. The Macro Name and Comment columns of such an AddMenu action (which normally specify the command name and status bar text for a command on the custom menu) are ignored, since this action defines a submenu, not a command on the top-level menu. You can create multiple levels of submenus by using AddMenu actions in the macro groups for each level of menu.
Macro conditions are supported in the top-level menu bar macro only. In other words, you can use a condition in a menu bar macro to determine if a particular menu will be displayed on the custom menu bar or global menu bar, but only for the menus on the top level of the menu bar. You can't use conditions to display or hide commands or submenus on the menus. You can also use a condition to hide or show a custom shortcut menu or global shortcut menu.
To run the AddMenu action in Visual Basic, use the AddMenu method of the DoCmd object. You can also set the MenuBar or ShortcutMenuBar property in Visual Basic to attach a custom menu bar or custom shortcut menu to a form, form control, or report. You can set the StartupMenuBar property (the programmatic equivalent of setting the Menu Bar box) to create a global menu bar. You can also set the MenuBar property of the Application object to create a global menu bar. Similarly, you can set the StartupShortcutMenuBar property (the programmatic equivalent of setting the Shortcut Menu Bar box) or the ShortcutMenuBar property of the Application object to create a global shortcut menu.