Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone Experiance the Loss of Global Variables??

Status
Not open for further replies.

WhiteZiggy

Programmer
Jan 22, 2003
85
US
Ok.

I am working on a database that I didn't write. I am fixing it though to the best of my ability and am running across an unusual error.

There is a form that when loading, loses the 'USER' variable that is populated at login. The exact time of loss is not specific. If you step through the code, it always works fine. Go figure. I have multiple 'DOEVENTS' in the code and have even gone so far as testing it with one after every line. This still does not always work.

It makes it the OnCurrent event, which is then used to populate the field. On the form I load an image, which can be very large at times. I have found a work around which is to populate the box (username) at the 1st step in the OnCurrent and then check to see if the global is still there at the end of the OnCurrent and repopulate it if it isnt. This appears to work 99% of the time.

I am thinking it is either 1) The image loading is causing it or 2) The network traffic is forcing the loss of it. (or a Combination of the 2).

Any suggestions or ideas?

Thanks in advance,
WZ
 
Probably code somewhere else is changing it. Try renaming your global and then do a Debug->Compile And Save All Modules and it will error every time something references the old global name. This way you can track down what's touching your global.

You could also use property subroutines to "encapsulate" the global variable, and put a msgbox or a breakpoint every time some code attempts to "Let global = etc".
 
Thanks but ,there is no code that is changing it. I tracked it step by step from login to opening of this form using F5. And did your suggestion. It gets set once when you login it, and that is the only changes to it.


I log in. Goto MainMenu, then Click to Load the NextForm. That is when it gets lost.

I have personally watched it be there at the top of the OnCurrent by using the debug window

?User

If it was being changed eveytime, I would see how it could be other code, but it simply a "fluke" that occurs approx ~25% of the time. The funniest thing, it only does it on certain machines. Not on all the machines. My machine NEVER does it, yet it is linked to the network the same as the others.

Forgot to mention, the DB is split with the tables on the network and the code on the local machines. The images to be loaded come from the network too.

Does anyone think it could be a lack of RAM?

Thanks ,
WZ
 
Don't think it's a lack of RAM. Instead of the variable just disappearing, you'd be more likely to get an Out of Memory error.

First thing I would elminate is possible confusion with the name "user". That may well be a keyword and it's possible that the DB Engine itself is using that for it's own purposes. So, the first thing I would do is change the name of the variable to something that is not a keyword.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
There is a case where if you have an unhandled error, and click End, it will reset every variable stored in every module of your project. So to work around this, put your global variable on a (hidden) textbox on a (hidden) persistent form so that your data is retained. This will definitely fix your problem, but won't identify what's causing it.


Good luck
 
Foolio,

That sounds like an ingenius idea. I think I will go with that.

Thanks for all the help from ALL of yall.
WZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top