passing a variable from one form to another

habbabub

Registered User.
Local time
Today, 08:58
Joined
Jan 24, 2008
Messages
73
how can i pass a variable from one form to another

this works fine
Tracking_Number = Forms("Main").Control("mytext")

but if "mytext" was in vb (rather than from a text box as shown above) how can i do this
 
A form is a class. If you create Let and Get variables it will work. Also a global variable will work. There are several more ways to do this. Try these first.

Enjoy!
 
how can i pass a variable from one form to another

this works fine
Tracking_Number = Forms("Main").Control("mytext")

but if "mytext" was in vb (rather than from a text box as shown above) how can i do this

And to expand on GUUS2005's answer -

If mytext was a variable (and in scope) then you could use

Tracking_Number = mytext
 
By the way, if you're on Access2007, check out the new feature: TempVars

It's a collection that lives as long as your DB is open, across forms and whatever... simple to use:

Code:
To store a value:
TempVars.Add "CustomerId", Me.CustomerId

To get it back:
sTemp = TempVars![CustomerId]
In the northwind, you'll find samples of it.
 

Users who are viewing this thread

Back
Top Bottom