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

Passing variable from one form to another

Status
Not open for further replies.

Syerston

Programmer
Jun 2, 2001
142
0
0
GB
I have found several threads for the following problem but I still cannot get it to work.

I need to pass a value contained in a variable from a pop up form to another form.

I have tried declaring it as a public variable in each form but to no avail.

Many Thanks
John

 
Hi,

Maybe this helps.

Name of Popup form = Form1
Var in Form1 = var1

Name of second form = Form2
Var in Form2 = var2

In Form2, write:

var2 = Forms!Form1!var1
or
var2 = Forms!Form1!.var1

try both.


You will need Form1 to be opened at the time when the code is executed. Later you can close it.


Klasse
 
Hi John!

Are you opening form from the other? If you are then you can use the following:

DoCmd.OpenForm "FormName", , , , , , YourVariable

To access the information in the second form use:

Me.OpenArgs

If the variable is not a string variable, then use conversion functions like format and CInt.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Jeff

Thanks for the help but I still couldn't get it to work.


For some reason it didn't like using Me.OpenArgs on the main form.

In the end I took the easy (but not very nice) way out, by populating two hidden text boxes on the form while the pop up form was open.



John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top