DoMenuItem Action

Description

You can use the DoMenuItem action to carry out a Microsoft Access menu command.

You can use this action to do the following:

  • Carry out any Microsoft Access command from a macro. You must select a command that is appropriate for your current view when the macro carries out the command. For example, a macro can’t carry out any of the Records menu commands if the active object is in table Design view, form Design view, query Design view, or report Design view.
  • Add a Microsoft Access command to a custom menu bar for a form or report, or to a menu on the global menu bar. For each command you want to add, enter a DoMenuItem action in the macro group for that menu.
  • Add a Microsoft Access command to a custom shortcut menu for a form, form control, or report, or to the global shortcut menu. For each command you want to add, enter a DoMenuItem action in the macro group for the custom shortcut menu or global shortcut menu.

Setting

The DoMenuItem action uses the following arguments.

Action argument Description
Menu Bar The name of the menu bar that contains the command you want to carry out. The Menu Bar box list in the Action Arguments section of the Macro window shows the different views in which menu bars appear. This is a required argument.
Menu Name The name of the menu that contains the command you want to carry out. The Menu Name box shows all menus on the menu bar that you selected with the Menu Bar argument. This is a required argument.
Command The command you want to carry out. The Command box shows all commands in the menu that you selected with the Menu Name argument. This is a required argument.
Subcommand The subcommand you want to carry out. This applies only if the desired command has a submenu.


Remarks

The DoMenuItem action has the same effect as clicking the specified command on a Microsoft Access menu. If clicking a command displays a dialog box, the dialog box is also displayed when you carry out the DoMenuItem action. You can use the SendKeys action to enter the appropriate information in the dialog box.

If you open a Microsoft Access version 1.x or version 2.0 database in Microsoft Access for Windows 95, the arguments for the DoMenuItem action in macros in this database show the appropriate menus and menu commands. However, you can’t edit objects from a version 1.x or version 2.0 database using a Microsoft Access 95 database. When you convert the database to Microsoft Access 95, the DoMenuItem action arguments will show the new menus and menu commands.

Note The Microsoft Access 95 File menu shows the most recently used databases. You can click one of these databases instead of clicking Open Database. These database items do not appear in the drop-down list for the Command Name argument for the File Menu, and are not available using the DoMenuItem action in a macro.

To run the DoMenuItem action in Visual Basic, use the DoMenuItem method of the DoCmd object.

See Also

AddMenu Action, DoMenuItem Method, SendKeys Action.