databaseLessons

Tips for MS Access users

23
Mar
2007

Option Explicit

by manxman

Just a friendly reminder. You need to ALWAYS use Option Explicit. Look at the top of any module of code, whether under forms or modules. The first two lines should be …

Option Compare Database
Option Explicit

By default, Access only puts the 1st one. You have two ways of getting the 2nd line in there.

  1. type it in manually, or,
  2. under Tools, Options in the VBA editor, turn on “Require Variable Declaration”

What does it do? Forces the “compiler” to make sure that EVERY variable has been declared. Basically, helps stop typos from causing “bugs”.

Just trust me on this one, and do it!

Leave a Reply