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

Using information from one form to another

Status
Not open for further replies.

rlusk49

Technical User
Nov 7, 2002
18
CA
I am trying to use information from one form on another form. Using the following code, the information actually appears in the text box on the second form but when I try to display the contents in a message box, it shows as empty. Any ideas?

FIRST FORM
Private Sub cmdSiblings_Click()

frmSiblings.lblName.Caption = lblName.Caption
frmSiblings.txtPersonID.Text = Me.txtPersonID.Text

frmSiblings.Show
Me.Hide

End Sub

SECOND FORM
Private Sub Form_Load()

Set mobjPerson = New CPerson
Set mobjParents = New CParents
Set mobjChild = New CChild
Set mobjSpouse = New CSpouse

MsgBox txtPersonID.Text

End Sub
 
First, it seems that you would want to reference txtPersonID.Text from the second form by putting the name of the first form in front of it (as in frmFirstForm.txtPersonID -- using the correct name of the first form, of course, in place of frmFirstForm).

Does that solve it for you?
 
You need to qualify your variable with the form name.

MsgBox frmSiblings.txtPersonID.Text
Thanks and Good Luck!

zemp
 
Try putting the code for frmSiblings into the Form_Activate procedure, rather than the Form_Load. That should fix your problem.

tbuch
 
Thanks tbuch

It worked under the Form_Activate procedure. Why wouldn't it work under Form_load?
 
When you referenced the second form, the form was loaded at that point. The form had to load BEFORE the data could be applied to the textbox.

tbuch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top