Module level variables

New Contributor

I am an experienced Access developer using Office 2013.

I have a form module where two module-level variables have their values set in the form open event, but when later checked in a button click event on the same form show as empty (one is string, the other boolean).

I have explicit turned on and have compacted/repaired and compiled.

Changing the variables from module to global fixes the issue, but that solution is not optimum.

Never seen this behaviour before. Any clues anyone?




2 Replies
Never seen the behaviour you describe, but without seeing your code it is hard to say for sure.

Are you in development where errors may occur testing the variables?
Have you decompiled and recompiled?
Why not use TempVars?


see below...

Are you in development where errors may occur testing the variables? Not that I'm aware of.
Have you decompiled and recompiled? Yes, it did not help
Why not use TempVars?

Why use Tempvars when the method I am trying to use is used elsewhere in the same database and works well. One other thing I omitted to mention is the if I step through the code in the form open event where the variable is assigned, and then put a breakpoint in the code where it is used - it works just fine. But if I just use the breakpoint at the place the variable is tested without stepping through the assignment - it fails.

Perhaps there has been a recent update that has stuffed things up?