Variables that hold user defined data after access closes?

ogg13

Registered User.
Local time
Today, 16:24
Joined
Jan 30, 2007
Messages
49
Is there a way to have a variable store data and retain that data, even after access closes? Ive tried what my limited knowledge allowed me to try which was making the variable a public variable in the main module, but that didnt seem to work..

As I write this, im thinking it would be possible by storing the data in a small table, then pulling it from the table into a variable. Id like to not have to have to do this though, if anyone has any ideas that might be helpful.

Thank you!
 
Variables only have limited life and do not survive after Access closes. You need to store it in either a table, an INI file, or the registry if you want to get it back when it reopens.
 
Yes, storing in an Access table is one good way of sorting variables amongst the others that Bob has mentioned.

One way…create your table like this:

Var1___Var2____Var3___Var4 …etc
“Bill”___256____30/2/7___-1…….etc

So each field in the table is a different variable. But importantly, there is only one row. Note that each variable can be a different data type.

To store a variable:
UPDATE Variables SET Var1 = "John"
etc

To retrieve a variable:
=DLookUp("[Var1]","Variables")
etc

Hope that makes sense. Apologies if I'm stating the obvious.

Stopher
 
Thanks, I feared I would have to go the route of the table 8)

Thanks again!
 
Heheh, I dont know, it just seems wierd being more attuned and knowledgable about structured coding than databases, and having to accept that I cant do what I wish to via code. Ive done it the way of the table and it wasnt so bad tho.. haha.
 
Here is the kicker that should decide for you.

You can't keep data in a variable any longer than the variable exists. If you know structured coding then you should know about variable constructors AND DECONSTRUCTORS. Why, then, would you expect the variable to hang around after the program level containing the item constructor wants to exit. Don't you think that same level would run the deconstructor?
 

Users who are viewing this thread

Back
Top Bottom