Public Variable

  • Thread starter Thread starter Janet Ciegler
  • Start date Start date
J

Janet Ciegler

Strange -- I've been doing this a couple of years but it doesn't work
today. A variable (blnZM) is declared as Public Boolean in a Module
("Declarations"). It is initialized in VBA code in the first form,
which then opens a second form. At the top of the code in the second
form, it has lost its value. I've checked the spelling in all places
and have followed its value in the Immediate Window. Some other vars in
the same Module seem to work OK, but I haven't checked all 65 vars.
What could be wrong? Do I need to reinstall the software? Thanks for
any ideas! I'm using Access 2000 and Windows XP for home. Jan
 
More info: When the boolean var is True, it gets passed to the next
form. But when it is False, the next form generates this message when I
try to evaluate the var, either within the program or from the Immediate
window:
Too few parameters.
Expected 1.
Other strange things have been happening today.
 
Jan,
Is there any chance that a variable of the same name has been declared in
the form Module of the second form? It would take precedence over the
variable in the standard module if that's the case. When you step through
the code, has the variable simply lost it's value or does it say it is "out
of context?"
 
Hello, Lynn,
Just rechecked, and no, I'm not reinitializing it in the second form.
Jan
 
Lynn, I think you got the answer! I had been fumbling for several hours
trying to get the data in the boolean variable to display as a check or
no check in the next form. Stupidly I was working with the Caption
rather than the Check on each box, and tried nearly everything until I
realized my mistake. So then I (again stupidly) left "blnZM" as the
name of the Caption. When just now I changed that to "ZM2", that solved
the problem. Thank you so much for pointing me in the right direction!!
Jan
 
Back
Top