Option Explicit not working

R

RzB

Hmmm... Just had a scary experience...

I accidentally miss-spelled a variable declaration -
a simple Dim of a string.. However, I had just done
a compile and realised that there had been no errors
reported.

I did a little experimentation and found that at least
some other modules did not have this problem. I found
that if I created a statement such as AAA = 99 with no
Dim of AAA and compiled, then the compiler not pick
it up in this one module, but the same statement in other
modules would be detected.

In options the "Require Variable Declaration" is set.

I compacted and repaired - no difference..

So I removed the two lines

Option Compare Database
Option Explicit

at the top of the rogue module, recompiled and the put the
two lines back...

hey presto the compiler finds the undeclared variable....

Does anyone have any idea what is going on? I have googled
but can't find anything similar in the NG history..

What is scary is that I have many, many modules... How do
I know if it's not working in other modules?

Thanks,
Roy
 
P

Paul Overway

Option Explicit must be present in ALL modules where you want variables to
be declared explicitly. Check all your modules to be sure the option is
present. Aside from that, it may be that your VBA project is corrupt and
needs to be decompiled....try opening your database with the /decompile
command line switch.
 
R

RzB

Paul,
Many thanks for your response..

Hmm... - Well that did summat...

The mdb went from 21Mb to 6Mb...

Methinks I'll run through the full regression test...

Do you know if there are there any areas I
should look out for in particular...

Thanks,
Roy
 
P

Paul Overway

In respect to looking out for something in particular, not really.
Decompiling, compacting, and recompiling are usually a good idea if you
notice strange behavior in your code though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top