DoCmd.RunDataMacro Method (Access)
Use the RunDataMacro method to run a named data macro from Visual Basic.
expression A variable that represents a DoCmd object.
Name of the saved macro. The name must include the name of the table to which the data macro is attached (for example, "Comments.AddComment").
Use the RunDataMacro method to reuse a named data macro in Visual Basic code.
If the data macro requires parameters, you must first create them using the SetParameter method prior to calling the RunDataMacro method. Each call to SetParameter creates a single named parameter.
The following code example creates two parameters for use by the AddComment data macro. The two parameters are named prmComment and prmRelatedID, respectively. The value of the txtComment textbox is stored in the prmComment parameter. The value of the txtId textbox is stored in the prmRelatedID parameter. The "Comments.AddComment" data macro is then run.