Option Compare Database vs. Option Explicit

Willem!

Registered User.
Local time
Today, 19:04
Joined
Apr 18, 2006
Messages
50
Hi!

I got a small question (once again). I have a fairly complete database which workes just fine. I have some modules that calculates stuff.

Now these modules were set up by my predecessor, and she placed in the top of all of these modules: 'Option Compare Database'.

As I am not an VBA-specialist I did not pay much attention to this. Now I just found some articles on the net which state that you should use 'Option Explicit Database'.

My question is: is that so? And can I replace without risk all the old headers?

Cheers,
Willem
 
They are two different things

Option Compare Database this results in string comparisons based on the sort order determined by the locale ID of the database where the string comparisons occur.

Option Explicit Database used at module level to force explicit declaration of all variables in that module. 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.

I tend to use both within my databases.
 
One should use both, but dont implement it into an excisting database. As you need to [explicitly] define your variables... Which may or may not have been done by the designer...

Groeten uit Amsterdam
 
Okay, thanks guys, learned some valuable information. I will treat the old database with care. Merci!

...en groeten vanuit Amersfoort ;)
 
Something to try, in order to see how careful the old designer was, is to put Option Explicit in the db (top of every module), then try and compile it (in the VB editor, go to the debug menu and click compile). This will highlight any non defined variable, and you can decide if you want to correct them all :)
 
well, that is a good tip! I'll try that out.

Cheers!
 

Users who are viewing this thread

Back
Top Bottom