Those pesky global variables.

S

Stuart

I am currently doing an Access97 project (unfortunate that it's not a later
rev, but that's what the client is using). I have established some global
variables, but something is overwriting them at times. For example, I have
an array that is global, I only assign values to it once, never update it,
but frequently it has nothing in it when I need to use it. Other variables
are getting "un-set" as well. Is there any known cause - or cure - for this
problem?

Thanks, Stuart
 
J

John Spencer

Do you have error-handling in your code? Any unhandled error will automatically
reset the variables to their nominal default values.

You can handle this by assigning your values to a temporary table, assigning
them to controls on a hidden form, or checking to see if they have appropriate
values and if not then repopulating them.
 
S

Stuart

John, thank you. I was unaware that unhandled errors will reset variables.
I do have error handling, but not everywhere. This gives me the direction I
need as to what to look for. Thank you.

Stuart
 
S

Stuart

It turns out there is another reason that a global variable can get
corrupted. If you open a form that has an unbound control on it with the
same name as the variable! Yes, I know I should be using more sophisticated
naming conventions. This is a good object lesson in why that is important.

Stuart
 

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

Top