RunCommand Method

See Also         Example         Applies To

The RunCommand method runs a built-in menu or toolbar command.

Syntax

[object.]RunCommand command

The RunCommand method has the following arguments.

Argument Description
object Optional. The Application object or the DoCmd object.
command An intrinsic constant that specifies which built-in menu or toolbar command is to be run.

Remarks

Each menu and toolbar command in Microsoft Access has an associated constant that you can use with the RunCommand method to run that command from Visual Basic.

For a list of possible constants for the command argument, see RunCommand Method Constants. You can also view these constants in the Object Browser. Select Access in the Project/Library box, then select AcCommand in the Classes list. The constants appear in the Members Of list.

You can't use the RunCommand method to run a command on a custom menu or toolbar. You can only use it with built-in menus and toolbars.

The RunCommand method replaces the DoMenuItem method of the DoCmd object.