Avatar of Jenkins
JenkinsFlag for United States of America

asked on 

Set the value of a textbox equal to a combobox value

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.
Microsoft Access

Avatar of undefined
Last Comment
Jenkins
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Try this:

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

mx
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Jenkins
Jenkins
Flag of United States of America image

ASKER

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


Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo