Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

You can use the RemoveTempVar macro action in Access desktop databases to remove a single temporary variable that you created by using the SetTempVar action.


The RemoveTempVar macro action has the following argument.

Action argument



Enter the name of the temporary variable you want to remove.


  • You can have up to 255 temporary variables defined at one time. If you do not remove a temporary variable, it will remain in memory until you close the database. It is a good practice to remove temporary variables when you are finished using them.

  • Access automatically removes all temporary variables when you close the database or project.

  • If you misspell the name of the variable to be removed, Access does not display an error. The variable you wanted to remove will remain in memory until you close the database.

  • If you have created more than one temporary variable and you want to remove them all at once, use the RemoveAllTempVars action.

  • To run the RemoveTempVar action in a VBA module, use the Remove method of the TempVars object.


The following macro demonstrates how to create a temporary variable, use it in a condition and a message box, and then remove the temporary variable by using the RemoveTempVar action.





Name: MyVar

Expression: InputBox("Enter a non-zero number.")



Message: ="You entered " & [TempVars]![MyVar] & "."

Beep: Yes

Type: Information


Name: MyVar

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!