RunCommand Action

RunCommand Action

See Also        

You can use the RunCommand action to run a built-in Microsoft Access command. The command may appear on a Microsoft Access menu bar, toolbar, or shortcut menu.

Setting

The RunCommand action has the following action argument.

Action argument Description
Command The name of the command you want to run. The Command box shows the available built-in commands in Microsoft Access, in alphabetical order. This is a required argument.

Remarks

In Microsoft Access 97, the RunCommand action replaced the DoMenuItem action. When you open and save a macro from a previous version of Microsoft Access that contains a DoMenuItem action, the action and its action 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.

You can use the RunCommand action to run a Microsoft Access command from a custom menu bar, global menu bar, custom shortcut menu, or global shortcut menu. However, it's normally easier to use the Customize dialog box, available by pointing to Toolbars on the View menu and clicking Customize, to add Microsoft Access commands to custom menus and shortcut menus. The Commands tab on the Customize dialog box lists the built-in Microsoft Access commands that appear on the Microsoft Access toolbars and menus.

You can use the RunCommand action in a macro with conditional expressions to run a command depending on certain conditions.

Note   The Microsoft Access 2000 File menu shows the most recently used databases. You can click one of these databases instead of clicking Open Database. These database items don't appear in the drop-down list box for the Command argument, and aren't available by using the RunCommand action in a macro.

When you convert a Microsoft Access database from a previous version of Microsoft Access, some commands may no longer be available. A command may have been renamed, moved to a different menu, or may no longer be available in Microsoft Access 2000. 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 command argument, or delete the RunCommand action.

To run the RunCommand action in Visual Basic, use the RunCommand method of the Application object. (This is equivalent to the RunCommand method of the DoCmd object.)