Temporary Variables

TempVar Object and TempVars collections enable developers to manage and exchange data between macros and VBA procedures. There are several factors to remember when working with a TempVar. First, a TempVar is created by using the Add method or the SetTempVar macro action. Second, once created, a TempVar object remains in memory until Access is closed, so it is a good practice to delete it after it has served its purpose. Take a minute to think about this and you'll recognize a tremendous benefit. This means that the TempVar can store a global variable and it will not lose its value if there is an error.

Third, you can delete one TempVar with the Remove method or the RemoveTempVar macro action or you can delete all TempVars with the RemoveAll method or the RemoveAllTempVar macro action. Either approach deletes the specified objects from the TempVars collection. Fourth, the TempVars collection has a limit of 255 TempVars. And finally, a TempVar can be referred to by its ordinal number or by its Name as specified in the property setting.

You spent some time with macros in Chapter 2 and you'll work with them again in the chapters on forms and reports.

Was this article helpful?

0 0

Responses

  • gordon
    How to set tempvar access 2007?
    8 years ago
  • gundolpho
    How to clear tempvars in vba?
    8 years ago
  • miikka
    How to set temporary variables in Access 2007?
    8 years ago

Post a comment