RunDataMacro Macro Action

Office 2013 and later

Last modified: July 28, 2015

Applies to: Access 2013 | Office 2013

In this article
Setting
Remarks
Example
About the Contributors

You can use the RunDataMacro action to run a named data macro.

The RunDataMacro action has the following argument.

Action argument

Description

Name

The name of the data macro to run.

You can use the RunDataMacro action in macros, named data macros, and the following macro events: After Delete Macro Event, After Insert Macro Event and After Update Macro Event.

The name of the data macro must include the table to which it is attached (for example, Comments.AddComment, not just AddComment).

When you select the data macro that you want to run in the macro designer, Access determines if the data macro requires parameters. If the data macro requires parameters, text boxes appear where you can type in the arguments.

When you run a macro that contains the RunDataMacro action and it reaches the RunDataMacro action, Access runs the called data macro. When the called data macro has finished, Access returns to the original macro and runs the next action.

The following example shows how to pass a parameter to a named data macro. The dmGetCurrentServiceRequest data macro of the tblServiceRequests table is called by using the RunDataMacro action. When the dmGetCurrentServiceRequest is finished, the CurrentServiceRequest variable returned form the data macro is written to the txtCurrentSR text box.

Sample code provided by: The Microsoft Access 2010 Programmer’s Reference

RunDataMacro
    Macro Name tblServiceRequests.dmGetCurrentServiceRequest

Parameters
    prmAssignedTo =[ID]

SetProperty
    Control Name txtCurrentSR
    Property Value
    Value =[ReturnVars]![CurrentServiceRequest]

Wrox Press is driven by the Programmer to Programmer philosophy. Wrox books are written by programmers for programmers, and the Wrox brand means authoritative solutions to real-world programming problems.

Show: