Subform Reference

  • Thread starter Thread starter PeterM
  • Start date Start date
P

PeterM

I have a form with a subform. I need to set a control on the subform from a
control on the form. In the code below, contacts is the form,
contactsaddresses is the subform. ComboName is the name of the destination
subform control. SourceName is the name of the control on the form.

Access cries that it cannot find the field comboname. I need the value of
ComboName to be used, i.e. "FirstName".

below is how I call the procedure and the procedure itself. How do I use
the value of comboname in the call.. not the literal "comboname"

Private Sub combo43_AfterUpdate()
MoveContactToAddresses Combo43, "firstname"
End Sub


Private Sub MoveContactToAddresses(ComboName As String, SourceName As String)
[Forms]![contacts]![ContactsAddresses].Form!ComboName =
Me(SourceName).Value
End If
[Forms]![contacts]![ContactsAddresses].Form.Refresh

End Sub
 
PeterM said:
I have a form with a subform. I need to set a control on the subform from
a
control on the form. In the code below, contacts is the form,
contactsaddresses is the subform. ComboName is the name of the
destination
subform control. SourceName is the name of the control on the form.

Access cries that it cannot find the field comboname. I need the value of
ComboName to be used, i.e. "FirstName".

below is how I call the procedure and the procedure itself. How do I use
the value of comboname in the call.. not the literal "comboname"

Private Sub combo43_AfterUpdate()
MoveContactToAddresses Combo43, "firstname"
End Sub


Private Sub MoveContactToAddresses(ComboName As String, SourceName As
String)
[Forms]![contacts]![ContactsAddresses].Form!ComboName =
Me(SourceName).Value
End If
[Forms]![contacts]![ContactsAddresses].Form.Refresh

End Sub


Try:

[Forms]![contacts]![ContactsAddresses].Form.Controls(ComboName) =
Me(SourceName).Value
 
THANK YOU!

Dirk Goldgar said:
PeterM said:
I have a form with a subform. I need to set a control on the subform from
a
control on the form. In the code below, contacts is the form,
contactsaddresses is the subform. ComboName is the name of the
destination
subform control. SourceName is the name of the control on the form.

Access cries that it cannot find the field comboname. I need the value of
ComboName to be used, i.e. "FirstName".

below is how I call the procedure and the procedure itself. How do I use
the value of comboname in the call.. not the literal "comboname"

Private Sub combo43_AfterUpdate()
MoveContactToAddresses Combo43, "firstname"
End Sub


Private Sub MoveContactToAddresses(ComboName As String, SourceName As
String)
[Forms]![contacts]![ContactsAddresses].Form!ComboName =
Me(SourceName).Value
End If
[Forms]![contacts]![ContactsAddresses].Form.Refresh

End Sub


Try:

[Forms]![contacts]![ContactsAddresses].Form.Controls(ComboName) =
Me(SourceName).Value


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
Back
Top