Module level variables

%3CLINGO-SUB%20id%3D%22lingo-sub-1651326%22%20slang%3D%22en-US%22%3EModule%20level%20variables%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1651326%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20an%20experienced%20Access%20developer%20using%20Office%202013.%3C%2FP%3E%3CP%3EI%20have%20a%20form%20module%20where%20two%20module-level%20variables%20have%20their%20values%20set%20in%20the%20form%20open%20event%2C%20but%20when%20later%20checked%20in%20a%20button%20click%20event%20on%20the%20same%20form%20show%20as%20empty%20(one%20is%20string%2C%20the%20other%20boolean).%3C%2FP%3E%3CP%3EI%20have%20explicit%20turned%20on%20and%20have%20compacted%2Frepaired%20and%20compiled.%3C%2FP%3E%3CP%3EChanging%20the%20variables%20from%20module%20to%20global%20fixes%20the%20issue%2C%20but%20that%20solution%20is%20not%20optimum.%3C%2FP%3E%3CP%3ENever%20seen%20this%20behaviour%20before.%20Any%20clues%20anyone%3F%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EChris%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1651326%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1652475%22%20slang%3D%22en-US%22%3ERe%3A%20Module%20level%20variables%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1652475%22%20slang%3D%22en-US%22%3ENever%20seen%20the%20behaviour%20you%20describe%2C%20but%20without%20seeing%20your%20code%20it%20is%20hard%20to%20say%20for%20sure.%3CBR%20%2F%3E%3CBR%20%2F%3EAre%20you%20in%20development%20where%20errors%20may%20occur%20testing%20the%20variables%3F%3CBR%20%2F%3EHave%20you%20decompiled%20and%20recompiled%3F%3CBR%20%2F%3EWhy%20not%20use%20TempVars%3F%3C%2FLINGO-BODY%3E
Highlighted
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?

Cheers

 

Chris

2 Replies
Highlighted
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?
Highlighted

@Daniel_Pineault 

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?