Wednesday, June 17, 2009 – Permalink –
VBA Variable Problems
It's good practice to always use the Option Explicit statement in the beginning of your code modules to ensure that all variables are unambiguously declared in your procedures.
With this process in place, you'll receive a "Variable not defined" error if you try to execute code containing undeclared variables. Without this statement, it's possible to mistype variable names, which would be interpreted as new Variant type variables.
This could severely impact the results of your code, and you might not ever know it. If you do find a problem, tracking down where the error is can be a chore.
Although you can manually type the statement into your modules, changing a setting in Access can ensure that the statement is always added to new modules.
See all Topics
<Doug Klippert@ 3:48 AM
Comments: Post a Comment