Query two fields into one combo box

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

Guest

tblCGStyles has two fields
txtCodeID (key
txtCorrugatedStyle

cbStyle in my form queries both of these fields

How do I get the two fields to display in the cbStyle after selecting? Currently, only txtCodeID displays.
 
Hi John,

A combo box will only display one column. But, there are
a few ways that you can do what you want to do.
Following are a few examples, both are variations of
concatenating the two fields into one:

1. Change your query such that the second column is a
calculated field that concatenates the two, and then hide
the first column (set the width to 0)

2. Concatenate the two colums as column 0 (the first
one) and set txtCodeID as the second column (column 1).
Change the combo properties such that it is bound to
column 1 instead of 0 (the default).

There are pro's and con's to each method. I often use
method # 1 if I want to do something like this.

The calculated field for your concatenation would look
something like:

[txtCodeID] & " - " & txtCorrugatedStyles

Where you would replace the " - " with whatever you would
want to display between the two column values.

HTH, Ted Allen
-----Original Message-----
tblCGStyles has two fields:
txtCodeID (key)
txtCorrugatedStyles

cbStyle in my form queries both of these fields.

How do I get the two fields to display in the cbStyle
after selecting? Currently, only txtCodeID displays.
 
A combobox won't display both in the textbox window, just in the drop down.
To display the other column after the selection, place a textbox next to the
combobox. Set its Locked property to Yes and, if desired, its Enabled
property to no. Set the control source of the textbox to

=NameOfCombobox.Column(1)

The column number is zero based, so the first column is 0, the second is 1,
etc. If you get an error, make sure that the name of the combobox is NOT the
same as the name of the field it is bound to or the name of any other item.

--
Wayne Morgan
Microsoft Access MVP


JohnLute said:
tblCGStyles has two fields:
txtCodeID (key)
txtCorrugatedStyles

cbStyle in my form queries both of these fields.

How do I get the two fields to display in the cbStyle after selecting?
Currently, only txtCodeID displays.
 
Back
Top