Drop down menus and storing multiple values

J

Jonathan

This seems like a simple question but it's driving me crazy. I have a drop
down menu that's pulling it's values from a column in another table and
storing it as text in Field A. Once a user has made a selection from that
drop down menu (or entered their own text) I want Field B to find and store a
numerical value from a different column (but same row) in the drop-down
source table.

In other words, I want one selection from a drop-down menu to set values in
two fields. How do I do this?

Any help is appreciated.
 
D

Douglas J. Steele

You need to use VBA. Put code like the following in the combo box's
AfterUpdate event:

Private Sub MyComboBox_AfterUpdate()

Me.SomeTextbox = Me.MyComboBox.Column(1)

End Sub

That will put the value from the second column of the selected row of the
combo box (the Column collection starts numbering at 0) into a text box
named SomeTextbox.
 
J

Jonathan

Thanks for the answer, but it's not working for me.

I wrote it out as follows:
Private Sub Combo16_AfterUpdate()
Form1.Text14 = Form1.Combo16.Column(1)
End Sub

I am getting

"Run-Time Error
'424':
Object Required"

Since this is my first trying to write VBA am I simply missing some extra
object identification or is my syntax screwy?

Thanks for he help.

Jonathan
 
D

Douglas J. Steele

The problem is your use of Form1.

Assuming this code is running in the class module for Form1, replace Form1
with Me in your code.

To refer to a form by its name, you'd need to use

Forms!Form1.Text14 = Form!Form1.Combo16.Column(1)
 

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