I wish to update the values in a column in a field in a table using an update query with the value of a variable called MonthVar which was declared in a module called modFunctions. How would I refer to this variable?
Microsoft ApplicationsMicrosoft AccessMicrosoft Office
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Then TempVars() is the slickest way to go.
Basically ... set your tempvar item (where ever)
TempVars.Add "SomeVarName", <value>
In your query - create an expression (or criteria) that retrieves the TempVar var using
TempVars(SomeVarName)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Two examples:
SELECT Table1.FIELD1, Table1.FIELD2
FROM Table1
WHERE (((Table1.FIELD3)=TempVars("YourVarName")));
SELECT Table1.FIELD1, Table1.FIELD2, TempVars("YourVarName") AS GetMyVar
FROM Table1;
Remember ... somewhere you have to initialize the TempVar item ... maybe in the On Load event of a Form, etc.
mx
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Another super cool thing about TempVars. IF ... an error occurs and a reset occurs - this does NOT hose the TempVar collection - just like if they were in a table.
mx