Those TempVars that June7 mentioned, available from 2007 forward, seem especially good to me because:
- Unlike Global Variables, they retain their values, even if an Error occurs
- They can be created in any Module, not just in a Standard Module, and still be available anywhere in the database.
Some Selected Syntax Examples
To Create a TempVars and Assign it a Value:
Code:
TempVars.Add "strCharacterName", "Bullwinkle Moose"
where 'strCharacterName' is the name of the TempVars and 'Bullwinkle Moose' is the value being assigned to it.
To Create and Assign Values for use as Text, Numbers and Booleans:
Code:
TempVars.Add "strCharacterName", "Bullwinkle Moose"
TempVars.Add "lngClientID", 123456789
TempVars.Add "boolApplyVAT", True
To Set or Re-set the Value of a TempVars after it has been created, elsewhere:
Code:
TempVars!strCharacterName = "Rocky J. Squirrel"
To Use the Value (in this case displaying it with a MessageBox)
Code:
MsgBox TempVars!strCharacterName
To Delete a TempVar:
Code:
TempVars.Remove "strCharacterName"
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007