Local Variables with Dim or Static

When you declare a local variable with the Dim statement, the value of the variable is preserved only while the procedure in which it is declared is running. As soon as the procedure ends, the variable dies. The next time you execute the procedure, the variable is reinitialized.

When you declare a local variable with the Static statement, the value of the variable is preserved after the procedure in which the variable was declared has finished running. Static variables are reset when you quit the Microsoft Access application or when a run-time error occurs while the procedure is running.

Introduction to Access 2003 VBA Programming

0 0

Post a comment