DoMenuItem Action

Description

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

Note In Microsoft Access 97, the DoMenuItem action has been replaced by the RunCommand action. The DoMenuItem action is included in this version of Microsoft Access only for compatibility with previous versions. When you open and save a macro from a previous version of Microsoft Access that contains a DoMenuItem action, the action and its arguments will automatically be converted to the equivalent RunCommand action. The DoMenuItem action no longer appears in the list of actions in the Macro window in Microsoft Access 97.

When you convert a Microsoft Access database from a previous version of Microsoft Access, some commands may no longer be available. The command may have been renamed, moved to a different menu, or is no longer available in Microsoft Access 97. The DoMenuItem actions for such commands can't be converted to RunCommand actions. When you open the macro, Microsoft Access will display a RunCommand action with a blank Command argument for such commands. You must edit the macro and enter a valid RunCommand action, or delete the action.

You can use this action to do the following:

  • Carry out any Microsoft Access command from a macro. You must select a command that's 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 or global shortcut menu.
Setting

The DoMenuItem action has the following arguments.

Action argument

Description

Menu Bar

The name of the menu bar that contains the command you want to carry out. The name of the menu bar is the name of one of the views in which menu bars appear. Enter the menu bar name in the Menu Bar box in the Action Arguments section of the Macro window. This is a required argument.

Menu Name

The name of the menu that contains the command you want to carry out. This is a required argument.

Command

The command you want to carry out. 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.

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

See Also

AddMenu action, DoMenuItem method, RunCommand action, SendKeys action.