referencing a subform from main form

slimjen1

Registered User.
Local time
Today, 08:03
Joined
Jun 13, 2006
Messages
562
All; I have a form and subform with the following names:

frmBasic
sfrmCustomers

I have a unbound txt field called txtCustName on the mainform
I want to populate this field from a field on the subform called CustName when the record is selected.

I also have an unbound combo box with the cust ids using the row source from the tables record source from the main form.

I tried the following Code:

Code:
Private Sub cboCustNum_AfterUpdate()
   Me.Filter = "[Cust_ID]=" & cboCustNum
   Me.FilterOn = True

Me.txtCustName = Forms.frmBasic.sfrmCustomers.Form.CustName
End Sub

This didn't work. So I put "= [Forms].[frmBasic].[sfrmCustomers].Form.[CustName]" in the control source of the text box on the main form I want populated.

The name doesn't appear in the field. I get #Name? in the field. What am I doing wrong please?
 
One thing to check is that you're using the name of the subform control on the main form, if different than the name of the subform itself.
 
Yes I've chked this several times. The name of the control is CustName and the subform is sfrmCustomers. The name of the main form is frmBasic. Is there something else? I need to get this figured out because next I need calculated fieids on the form from the subform.
 
You miss my point. There is a subform control on the main form, which has sfrmCustomers as its source object. In other words, the subform is within a subform control. The name of that control may or may not be sfrmCustomers. Can you post the db here?
 

Users who are viewing this thread

Back
Top Bottom