Book

Suggestions


Enter your email address:

Delivered by FeedBurner


Home Page

Bloglines

1906
CelebrateStadium
2006


OfficeZealot

Scobleizer

TechRepublic

AskWoody

SpyJournal












Subscribe here
Add to 

My Yahoo!
Use your pdf converter to make your pdf files easy! You can now buy software that makes converting pdf to doc possible! Did you know you can even convert pdf to word?

This page is powered by Blogger. Isn't yours?

Host your Web site with PureHost!


eXTReMe Tracker
  Web http://www.klippert.com



  Wednesday, June 17, 2009 – Permalink –

VBA Variable Problems

Explicit protection


It's good practice to always use the Option Explicit statement in the beginning of your code modules to ensure that all variables are unambiguously declared in your procedures.

With this process in place, you'll receive a "Variable not defined" error if you try to execute code containing undeclared variables. Without this statement, it's possible to mistype variable names, which would be interpreted as new Variant type variables.

This could severely impact the results of your code, and you might not ever know it. If you do find a problem, tracking down where the error is can be a chore.

Although you can manually type the statement into your modules, changing a setting in Access can ensure that the statement is always added to new modules.

  1. Open a module (start the VBA Editor)

  2. Choose Tools>Options from the menu bar

  3. On the Editor tab of the Options dialog box, select the Require Variable Declaration check box in the Code Settings panel

  4. Finally, click OK





See all Topics

Labels:


<Doug Klippert@ 3:37 AM

Comments: Post a Comment