Combo box value populates text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to have the value chosen in a combo box on one form to be
displayed in a text box on another form. How do I do that?
 
In the AfterUpdate event procedure of the combo box ...

Forms!NameOfOtherForm!NameOfTextBox = Me!NameOfComboBox
 
Hi,
Do you want it to be displayed as soon as the selection is made or when the
new form is navigated to?, also is the other form open? as there are a couple
of options you can take. Both the options I have are also done through VBA I
would not say they are hard but you will need some knowledge of how to access
it.

Option 1:

If the target form is already open then setting the controls contents is
done using a simple bit of vba on placed into the combo's 'On Change' event
(found in the properties) the vba is below (remember this will only work is
the targer form is already open): -

Forms!Form2.Text0.Text = Combo0.Column(1)

Replace the 'Form2' with the name of your target form and replace 'Combo0'
with your combo's name, the Column option on the Combo .Column(1) tells the
system what column you want to display (0 being the first column) as most
combos will contain more than one columns (if your combo only has one column
just put the combo name without the .Column(1) bit).

Option 2:
If the change is to happen when the target form is opened then you will need
to use the target forms On Load event and you can use almost the same code
for this but swap the forms bit around: -

Text0.Text = Forms!Form1.Combo0.Column(1)

I hope from this you can find a solution to your problem.

Mike J. Soames
 
Thanks very much for you answer. I thought this would work, but every time I
try to select a value in the combo box I get Run time error 2465 and it says
it can't find the field although I checked to make sure field name matched.
 

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

Back
Top