Losing global and module level variables

Rob.Mills

Registered User.
Local time
Today, 12:37
Joined
Aug 29, 2002
Messages
871
Does anyone know what would cause a module level variable to lose it's value while an application is in use?
 
When it goes out of scope.

Which can happen for many reasons, but basically the code that set its value is finished running.

Have you stepped thru the code to see what is actually happening?

??
 
I was under the understanding that a module level variable exists until you change it or the application closes.

I haven't stepped through the code because I don't know when this is occuring. I didn't write any code to make it equal nothing.

Basically I have a module variable that is an object and its value set on open of the form. It should remain the entire time the form is open. But sometimes when a method is called in that form that uses that object I get the error message saying that it does not equal anything.

I want to figure out how to prevent this from happening.
 
Any variable value is null until a sub or function sets it to a value. That will remain its value until it is reset by code, or when the function stops running.

Modules are not 'running' when the app opens until they are called.

Place a breakpoint on the code in the module, and step thru the code when the form opens. Do it again when the other method is called and you should be able to determine why it is changing the value of the variable.
 
Last edited:
Right at the moment I'm having a challenge recreating the error. The only place I have code set the variable to nothing is on close of the form. But users seem to be getting the message that it's not set to anything before they're closing it.
 
Rob:

Set a watch on the variable in the module.

Place a breakpoint at a conveneint spot in the code in the module in question, and step thru the code when the form opens.


Do it again when the other method you referred to is called and you should be able to determine why it is changing the value of the variable.
 

Users who are viewing this thread

Back
Top Bottom