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

Sending value through global variable

Status
Not open for further replies.

rry2k

Programmer
Jun 28, 2001
678
US
I would like to send the value that is selected in a combo box to a textbox on a second form. I thought I could setup a global variable like public passname as string, then use
passname = combo1.value on form1 and
txtname.text = passname on form2 but that doesn't work.

Thanks..Russ
 
Should work, did u try to refresh the form. I've done similar stuff before without trouble. But, I did not use a public variable. Rather I would refrence the other form value. htwh... Steve Medvid
"IT Consultant & Web Master"
 
When I view the variable contents in the 2nd form it is blank. What did you mean by reference the other form value??
 
Just did a little test... On Form1 I have Text1 on Form2 I have Text2. Seems to work ok when I have change on value of Form1 and exit the field. Another approach is to check on Form2 Activate event to grab value from form1.

Private Sub TEXT1_Exit(Cancel As Integer)
Forms!form2.text2.Value = Me.TEXT1.Value
Forms!form2.Refresh
End Sub
Steve Medvid
"IT Consultant & Web Master"
 
Are you using a subform for this? I'm using 2 distinct forms and can't seem to get your code to work.

Thanks..R
 
Nope... 2 differnt forms... Form1 and Form2. Form1 has a text box called Text1. Form2 has a text box called Text2. The Text1 - On Exit event is where I have the code to populate and refresh the Text2 field. Make sure both forms are open and non-modal. U just have to play with it to learn it... htwh
Steve Medvid
"IT Consultant & Web Master"
 
That's where I'm losing it. On the keeping form1 open.
I'm opening form2 with a macro but it seems to automatically close form1.

???
 
Just open them both up without a Macro to see how stuff works. Open the database. Lauch form1. Click the database and Launch form2. Personally, I stay away from macros since there is limited error handling capabilities. Steve Medvid
"IT Consultant & Web Master"
 
Thanks for the help Steve. I ended up using docmd's and it worked fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top