SetReturnVar macro action
Applies to: Access 2013, Office 2013
The SetReturnVar action creates a return variable and sets it to a specific value.
Note
The SetReturnVar action is available only in Data Macros.
Setting
The SetReturnVar action has the following arguments.
Argument |
Required |
Description |
---|---|---|
Name |
Yes |
A string that specifies the name of the variable. |
Expression |
Yes |
An expression that will be used to set the value for this temporary variable. Do not precede the expression with the equal sign (=). You can click the Build button to use the Expression Builder to set this argument. |
Remarks
The SetReturnVar action is used to create a ReturnVar, which is variable that can be used by macros that call a data macro by using the RunDataMacro action.
Once a ReturnVar is created by the SetReturnVar action, the calling macro can use it in an expression. For example, if you created a ReturnVar named UpdateSuccess, you could use the variable by using the following syntax:
=[ReturnVars]![UpdateSuccess]
The SetReturnVar action can be used only in named data macros. It is not available in data macros that are attached to a data macro event.
Example
The following example shows how to use the SetReturnVar action to return a value from a named data macro. A ReturnVar named CurrentServiceRequest is returned to the macro or Visual Basic for Applications (VBA) subroutine that called the named data macro.
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]