DoCmd.RunMacro (Access)

The RunMacro method carries out the RunMacro action in Visual Basic.

You can use the RunMacro method to run a macro. You can use MacroGroupName.MacroName syntax 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 that you specify.

RunMacro (MacroName, RepeatCount, RepeatExpression)


DoCmd.RunMacro "Print Sales", 2

Arguments

The following argument is required

MacroName (String) - A string expression that's the valid name of a macro in the current database. If you run 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.

Optional arguments

The following arguments are optional

RepeatCount (Long) - A numeric expression that evaluates to an integer, which is the number of times the macro will run.

RepeatExpression (Long) - A numeric expression that's evaluated each time the macro runs. When it evaluates to False (0), the macro stops running.