Combo Box selection to help populate form

G

Guest

Yes, another stupid question.

Combo box that has a query as its control source. When the user selects one
of the items in the combo box, I want a second text box to show the result of
another field in that query.

Example: Combo box is list of state abbreviations. When the user selects
"TX", I want the text box to display "Texas". Both fields are in the query.

Thanks!
 
M

Marshall Barton

So said:
Combo box that has a query as its control source. When the user selects one
of the items in the combo box, I want a second text box to show the result of
another field in that query.

Example: Combo box is list of state abbreviations. When the user selects
"TX", I want the text box to display "Texas". Both fields are in the query.


Set the text box's control source expression to:

=thecombobox.Column(1)
 
G

Guest

If you have both values in your query, set up a column in your combo for them.

Say your combo's query is something like:
Select StateAbbrv, State From tbl States

You would have 2 columns in your combo.
Your textbox's ControlSource would need to be: =MyCombo.Column(1)

Combo column indexes are zero based so 0 is first column, 1 is second and so
on...

What are you storing?
If you want to store TX but display Texas, using the above select statement,
you would have 2 columns. Column 1 being the bound column (the first column
in this case). In the column widths property, you would set the first column
to 0 and the second to say 3cm (or whatever measurement you are using).
0cm;3cm
The combo will display the first non-zero width column but will always store
the value of the bound column in your table.

Steve
 
G

Guest

Or if you wanted to use the combobox to select a record from the current
recordset you could do something like this.

' Find the record that matches the control.
' ExpressFind Combobox displays 'Class Names' and contains 'ClassId' as
value
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ClassId] = " & Me.ExpressFind.Value
Me.Bookmark = rs.Bookmark

HTH
Mitch
 
G

Guest

Thank you guys SO MUCH!! I knew that I knew how to do this, but darn if I
could jog it out of my old brain!!
 

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