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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables Losing Information!!

Status
Not open for further replies.

hiker0310

MIS
Apr 3, 2002
14
US
I have been using variables for a while. Now when the database is running (Access 2003), some of the variables will lose their information and revert to empty. If anyone can help I would be thankful. There are no errors that I can see that are stopping the code. Please help if you have any answers.
 
How are ya hiker0310 . . . . .

Your problem could very well be [blue]Variable Scope & LifeTime.[/blue]

Pick one of the variables as an example an answer the following:
[ol][li]Exactly [blue]where[/blue] does the variable reside?[/li]
[li]How is the variable declared (post the code line for it)?[/li]
[li]Perform a search (find) fron any VBE window for the variable (be sure to check [blue]Current Project[/blue]) and as you step thru find, look for any line that resets/clears the variable.[/li][/ol]


Calvin.gif
See Ya! . . . . . .
 
hiker0310 . . . . .

Hit submit too soon.

If any of the variables are in [blue]form modules[/blue], there [purple]only available as long as the form is open [/purple]. . .

Calvin.gif
See Ya! . . . . . .
 
ALL the global variables are getting lost but what ever Form I am currently on does not loose it's vars. I assume this is because the form has not lost scope yet. I thought that global variables held their settings until the project was closed?

The variables are global variables that I am using. They are declaired in a module and not a form module(class module?). This is an example of the code used to set the vars. This is just one out of all of them that are getting lost.

Option Compare Database
Option Explicit

Public gfnUserFullName As Variant

gfnUserFullName = DLookup("[FullName]", "Login_Verification", "Username= Forms!Login_Screen!UserName And Password= Forms!Login_Screen!Password_Entry")

Public Function FullUserName()
FullUserName = gfnUserFullName
End Function

Hope this helps. I could realy use the help on this one.
 
And your module compiles OK ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
yes, compiling the code works without a hitch. The module the variable is in is called UserSettings. I doubt this has any bering. Again please help if you can. I am lost!
 
I changed the Module that the code was in and it still does not hold the variables. The Variables are set to Public in the global code module and I loose the variables when I go from a form to it's sub form. SO that seems to be the link. I still have no clear understanding of why. Please Help.
 
hiker0310 . . . . .

Under what conditions are you noticing the variables are lost?

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top