Share via


RunDataMacro Macro Action

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: Access 2010 Programmers Reference book cover The Microsoft Access 2010 Programmer’s Reference | About the Contributors

RunDataMacro
    Macro Name tblServiceRequests.dmGetCurrentServiceRequest

Parameters
    prmAssignedTo =[ID]

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

About the Contributors

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.