Subform Reference

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
 
D

Dirk Goldgar

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
 
P

PeterM

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top