RunMacro Method

Applies To

DoCmd Object.

Description

The RunMacro method carries out the RunMacro action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.RunMacro macroname[, repeatcount][, repeatexpression]

The RunMacro method uses the following arguments.

Argument

Description

macroname

A string expression that is the valid name of a macro in the current database.

If you execute Visual Basic code containing the RunMacro method in a library database, Microsoft Access looks for the macro with this name in the library database and doesn’t look for it in the current database.

repeatcount

A numeric expression that evaluates to an integer, which is the number of times the macro will run.

repeatexpression

A numeric expression that is evaluated each time the macro runs. When it evaluates to False (0), the macro stops running.


Remarks

You can use “macrogroupname.macroname for the macroname argument to run a particular macro in a macro group.

If you specify the repeatexpression argument and leave the repeatcount argument blank, you must include the repeatcount argument’s comma. If you leave a trailing argument blank, don’t use a comma following the last argument you specify.

See Also

DoCmd Object.

Example

This example runs the macro Print Sales.


DoCmd.RunMacro "Print Sales"