Set the value of a textbox equal to a combobox value

dbfromnewjersey
dbfromnewjersey used Ask the Experts™
on
I have a combobox on a main form.  The main form does not have a record source.  The record source of the combobox is a table.

I have a subform on the main form. The subform's record source is a table (different from the one tied to the combobox).  I have a textbox in the header area of the subform. I want to set its value to whatever the combobox's value is.  If the combobox value changes, I want the textbox value on the subform to change.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
Try this:

Private Sub Combo1_AfterUpdate()
    Me.YourSubformControlName.Form.YourTextBoxName = Me.Combo1
End Sub

mx
Database Architect / Application Developer
Top Expert 2007
Commented:
Change the Names below accordingly of course ...

Private Sub Combo1_AfterUpdate()
    Me.YourSubformControlName.Form.YourTextBoxName = Me.Combo1
End Sub
Top Expert 2016
Commented:
first of all.combo boxes does not have record source, they use row source.

place this codes in the afterupdate of the combo

me.subformcontrolname.form.textboxname= me.combo0

if you want to show a different column from the combo


me.subformcontrolname.form.textboxname= me.combo0.column(1)  ' will display the seoncd column of the combo, you have to set the combo column count property to 2 or greater to make this work
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
:0

Author

Commented:
This is what I already had under the After Update event of the combobox:


Private Sub MyComboBox_AfterUpdate()

With DoCmd
   .SetWarnings False
   .Hourglass True
   .OpenQuery "DeleteTemporaryTable"
   .OpenQuery "PopulateTemporaryTable"
   .SetWarnings True
   .Hourglass False
End With
   
   Me!MySubform.Form.Requery

Adding this code to the event is causing a 440 run-time error:

 Me.MySubform.Form.MyTextbox = Me.MyComboBox


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial