Jeff said:
Dirk,
Thanks for the reply...
I think I am making this harder than it is.....
OK...I have a textbox on my subform called txb_Name that is unbound. The
subform is sourced to a query that has an EmployeeName and a ClientName. On
the main form I want to set the control source of the txb_name to either
"ClientName" or "EmployeeName".
In the On Update event of my cbo_Employees(on the main form) I want to reset
the Control Source of the txb_Name (on the subform) to "EmployeeName" and
same with the cbo_Clients.
This way the subform displays EmployeeNames or ClientNames depending on the
combobox that is updated last. Clear as mud huh
How do I reset the control source of the txb_name in the subform?
I think I see. You want the subform's text box, txb_Name, to be bound to
EmployeeName when the user updates cboEmployees on the main form, and to
ClientName when the user updates cboClients on the main form. I have some
reservations about what's going to happen if the main form is bound and
moves from record to record, but that's another question.
For what you're asking, you could use these two event procedures:
'----- start of code -----
Private Sub cboEmployees_AfterUpdate()
Me!SubformControlName!txb_Name.ControlSource = _
"EmployeeeName"
End Sub
Private Sub cboClients_AfterUpdate()
Me!SubformControlName!txb_Name.ControlSource = _
"ClientName"
End Sub
'----- end of code -----
You'll have to modify the above code to replace "SubformControlName" with
the name of the subform control (on the main form) that is displaying the
subform. This may or may not be the same as the name of the form object the
subform control is displaying.
Note also that changing the controlsource of this text box isn't going to
change the way the subform is linked via the Link Master/Child Fields.