Option Explicit

  • Thread starter Thread starter Michael S. Montoya
  • Start date Start date
M

Michael S. Montoya

I realized that I forgot to add the Option Explicit to my code. I had read
having this line can speed up a database.

Is there a way to quickly add this to all of my forms/modules?
 
In the code window, bring up the find/replace dialog (Ctrl+H).

Search for: Option Compare Database
Replace with: Option Compare Database: Option Explicit
Search what: Entire Project

VBA will accept two commands on the same line separated by a colon. I
couldn't get the Search/Replace dialog to to accept a carraige return to
place them on separate lines.
 
I don't think it is there to speed up the execution of code.

The purpose of Option Explicit is to make the declaration of (VBA) variables
compulsory, i.e. the code will error out if the variable is not declared
with the Dim statement. When you compile codes in the Module, any variable
that is not declared will give you a Compile Error - Variable not declared.

If you don't use this, mis-typed names will be considered as valid variables
which can create unexpected (and hard-to-diagnose) results.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top