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!

Passing Variables Between Forms 2

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
I have an application with multiple forms. What I want to do is share the value of the variables between forms, however the variable is not in a text box or other object. Is this possible?

for example, I declare username a global variable on one form. when a second form opens, i don't want to repeat the environ, i just want to get the value from the other form, which is still open.

I tried the code below, but it is looking for a text box,etc.
Private Sub Command0_Click()
Dim Mike As String
Mike = Forms!QVLog!UserName
QVLog is the form with the value, and Username is the variable in memory.

Any suggestions?

thank you
 
If you are Dim'ing the global variable at the form level then it will only be available to other subs and functions IN THAT FORM.

If you want it to be available throught the entire mdb the Dim it as Public in module in the General Declarations section.



I tried to have patience but it took to long! :) -DW
 
Provided that UserName is declared as Public in the declarations section of QVLog's class module:
Mike = Forms!QVLog.UserName

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top