RunDataMacro macro action

Applies to: Access 2013, Office 2013

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

Setting

The RunDataMacro action has the following argument.

Action argument

Description

Name

The name of the data macro to run.

Remarks

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.

Example

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]