Solved: Running A Recorded Macro From A Button

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.
Joined
Aug 5, 2005
Messages
3,086
DoCmd.RunMacro MacroName, [RepeatCount], [RepeatExpression]

Originally posted by Microsoft Access 2000 help docs:

RunMacro Method

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 has the following arguments.​

Argument Description

macroname

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.​

repeatcount

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

repeatexpression

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

Remarks

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 you specify.​
RunMacro Method Example

The following example runs the macro Print Sales that will print the sales report twice:

DoCmd.RunMacro "Print Sales", 2
chris.
 

coachdan32

Thread Starter
Joined
Nov 13, 2003
Messages
1,021
Thanks Chris. I thought that was it - my problem turned out to be with the macro itself.
 
Joined
Jul 25, 2004
Messages
5,458
I would recommend using the Call method if the macro/procedure is in the same workbook that it's being called from. If not, I generally use the Application.Run method.
 
Joined
Aug 5, 2005
Messages
3,086
Oh. Yeah, I didn't even think about it, I just assumed the application was Access because CoachDan always posts in Access threads.

Thanks for spotting that, Zack (y)

chris.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top