DoCmd.RunDataMacro (Access)

Use the RunDataMacro method to run a named data macro from Visual Basic.

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 by using the SetParameter method prior to calling the RunDataMacro method. Each call to SetParameter creates a single named parameter.

RunDataMacro (MacroName)

MacroName: 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).


Private Sub cmdAddComment_Click() 
DoCmd.SetParameter "prmComment", Me.txtComment 
DoCmd.SetParameter "prmRelatedID", Me.txtId 
DoCmd.RunDataMacro "Comments.AddComment" 
End Sub