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!

Temporary Table 2

Status
Not open for further replies.

KalEl33

Programmer
May 20, 2002
17
US
I need to temporarily store a value that is entered by the user on a form. Another form would use that stored value then delete the value. My goal is to make sure that the second form can alway access the newest user value. Is a temporary table the best way to do this? And if so how do I go about creating one.

Thanks in advance.

Sincerely,
Kal-El
 
Hiya,

Sounds like you need to define a global variable, i.e. a variable that will hold a single value for the lifetime of the application and which can be changed by any form within the application.
Once the application is closed, then the value will be lost.

I don't know the type of data to be held, so we won't define the variables' type....

Open up your application module, within it type:

global MyVar

You can now refer to MyVar as if it was a normal field on any form, except that you never need to qualify it.

E.G. MyVar = 10 or MyForm!MyField = MyVar etc.

Because we didn't declare the type of data that MyVar will hold, it will hold any type of data: strings, numbers anything.

If you know the type of data beforehand, then define it as that type.....

Global MyVar as String or
Global MyVar as Integer or
Global MyVar as Byte etc. etc.

Obviously you can name the variable anything that you wish - it doesn't have to be 'MyVar' !!!

Hope this helps,

Darrylle






"Never argue with an idiot, he'll bring you down to his level - then beat you with experience."
 
Darrylles is correct that a Global variable is the most likely way of handling this common situation. Be aware of a pitfall with all ACCESS development. You must actively trap for Run-Time errors in your code because you will lose the stored value of any variables whether global or local when an error occurs and is not handled through code.

Research error trapping techniques in ACCESS help and other sources. I have learned the hardway and just wanted to pass this along as advise. A parallel alternative is to have a single record server based table that can have many variables/fields stored. These fields can be updated and then retrieved at any time by any users.

I don't want you to misunderstand. I use Global variable a lot but I also use the alternative as described above in certain circumstances.

Bob Scriver
 
Thank you Gentlemen. Your advise really helped.

Sincerely,
Kal-El
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top