Require variable declarations for Visual Basic code

Microsoft Office Access 2003

Show All Show All

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.

  1. On the Tools menu, click Options.
  2. Click the Editor tab.
  3. Under Code Settings, select the Require Variable Declaration check box.