Calling Textbox value from another form

jon2371

Registered User.
Local time
Today, 08:28
Joined
Aug 2, 2012
Messages
20
Hi Expert,

I have two forms (mainform&subform), i need to copy the textbox1.value from mainform to the subform textbox2. i tried the code below but still i encounter the code error. The txtqty2 is located in subform. Please help me.

Private Sub txtqty2_AfterUpdate()
Me.textbox2= 'Form!mainform!textbox1
End Sub

Thanks!
Jon
 
Is your Main Form called mainform :eek: if not you need to replace that with the actual name of your main form.
 
As you have typed it you have a ' that is not needed and an ! instead of a .

Me.textbox2= Form!mainform.textbox1 is the correct syntax.

Alternatively you could just set the controlSource of textbox2 as =Form!mainform.textbox1.
 
Sorry, this is my actual form & texbox name
Main Form :
HeadRejectMachF (Form)
cboMachineNo (ComboBox)
SubForm :
DetailRejectMachSF (Form)
txtMachineNo2 (TextBox)
txtQty2 (TextBox)


I need to update my subform (DetailRejectMachSF) txtMachineNo2 value based on cboMachineNo from mainform (HeadRejectMachF).

i tried this syntax:
Private Sub txtQty2_AfterUpdate()
Me.txtMachineNo2 = Form!HeadRejectMachF.cboMachineNo.Value
End Sub

Thanks,
Jonathan
 
Try;
Code:
Private Sub txtQty2_AfterUpdate()
Me.txtMachineNo2 = Form!HeadRejectMachF[B][COLOR="Red"]![/COLOR][/B]cboMachineNo.Value
End Sub

Check this link for the various syntax for referring to forms, subforms and their properties from various relative locations.
 
You could also use;
Code:
Me.txtMachineNo2 = Me.Parent!cboMachineNo.Value
 
Thank You Sir John, it fixed my prob...
Me.txtMachineNo2 = Me.Parent!cboMachineNo.Value
Thanks a lot..

Jon
 

Users who are viewing this thread

Back
Top Bottom