Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Explicit Explanation 2

Status
Not open for further replies.

perrymans

IS-IT--Management
Nov 27, 2001
1,340
US
I ran the Performance Analyzer and it said I needed to declare my form code Option Explicit.

How big a deal is this? Will it break things? Reworking of code involved?

I don't really know what it is anyway.

Thanks. Sean.
 
You could look at any Access programming book.
Briefly, code is kept in a module. Modules have a special section called the Declarations section. You declare variables and constants that apply to the entire module there.
Options set options for the whole module.
Explicit is a keyword for Options which tells Access to check all the varible names you use in the module to make sure you've declared them. It helps to catch typos. If you don't have this statement, you can pretty much type anything you want in a module. It probably won't work, but that's your problem.
 
You will probably want to do Option Compare Database as well.

Sure, the early bird gets the worm, but the second mouse gets the cheese in the trap.
 
How are ya perrymans . . .
Microsoft said:
[blue]Used at module level to force explicit declaration of all variables in that module.

Syntax

Option Explicit

Remarks

If used, the Option Explicit statement must appear in a module before any procedures.

When Option Explicit appears in a module, you must explicitly declare all variables using the Dim, Private, Public, ReDim, or Static statements. If you attempt to use an undeclared variable name, an error occurs at compile time.

If you don't use the Option Explicit statement, all undeclared variables are of Variant type unless the default type is otherwise specified with a Deftype statement.

Note Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear.[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Thanks fellas, I'll go ahead and put it in eveywhere.

Thanks. Sean.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top