Require variable declarations for Visual Basic code
Microsoft Visual Basic doesn't automatically require that you explicitly declare a variable before using it in a procedure. If you use a variable that hasn't been explicitly declared, Visual Basic implicitly declares it as a variable with the Variant data type. Although implicit declarations are convenient, they can lead to subtle errors in your code.
You can require that variables be declared before they are used in a procedure. Microsoft Access automatically includes an Option Explicit statement in the Declarations section of all new modules in the database, including the form and report modules associated with new forms or reports.
- On the Tools menu, click Options.
- Click the Editor tab.
- Under Code Settings, select the Require Variable Declaration check box.