From the course: Access 2019: Macros

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use temporary variables

Use temporary variables

From the course: Access 2019: Macros

Start my 1-month free trial

Use temporary variables

- [Adam] Access Macros support the use of variables that can be set, modified, and removed over the course of the Macro's execution. Let's open up a new Macro in the designer, and in the action catalog I'm going to expand the Macro Commands folder. There's two different actions that I want to take a look at. The first is SetLocalVar. SetLocalVar will establish a local variable that can only be used inside of the Macro, and it exists only until the Macro finishes. As soon as the Macro completes its process the variable is removed from memory. The other one that I want to take a look at, if I scroll down, is the SetTempVar action. This one establishes a temporary variable. These'll persist after the Macro finishes, and can be used outside of the Macro, for instance in a form or another Macro. Access will remember up to 255 temporary variables, but they all get removed when the database is closed. It's important to remember to run the RemoveTempVar action, here, when the variable is no…

Contents