I want to see more than one column in a combo box

  • Thread starter Thread starter Kjell Harnesk
  • Start date Start date
K

Kjell Harnesk

I have a combo box with 2 columns, both are visible when I click the arrow
but only the bound column is visible after the choise is made. Is there a
way to show both columns at all times?
 
Kjell

Access comboboxes display a single column's data, except when dropped-down
(to make choosing the correct item easier). If you want to display another
column from the chosen row on your form, you can:
add an unbound textbox
in the AfterUpdate event of the combobox, add code something like:
Me!txtNewUnboundTextbox = Me!cboYourComboBox.Column(n)
where Column(n) refers to the n-1 column in the source of your combobox.
Check Access HELP for more information about using this zero-based method
(Column()).
 
Kjell said:
I have a combo box with 2 columns, both are visible when I click the
arrow but only the bound column is visible after the choise is made.
Is there a way to show both columns at all times?

No, but you can place a TextBox right next to it with a ControlSource of...

=ComboBoxName.Column(n)

....where 'n' is the zero-based value of the column you want. This will only
*display* the value of the second column. It will not store it as part of the
record in the underlying table of the form, but this is usually the desired
behavior anyway.

If there is a reason you need the value stored as part of the record then you
would use the AfterUpdtae event of the ComboBox with...

Me.TextBoxName = Me.ComboBoxName.Column(n)
 
No, there isn't.

As a kludge, you could base the combobox on a query that includes a computed
field that concatenates all of the necessary information into a single
field, and have that field displayed.
 
You can accomplish the effect that you are looking for (and that I >was<
looking for) by using a listbox instead (it takes some trial and error, but
just shrink the height of the listbox down to the size of one row's height
and, volia, a "pseudo-combo box" which displays more than one column as its
selection). Of course, with a listbox the user must select from a list and
cannot enter a value using the keyboard like a combo box permits -- but it
serves its purpose for me.

Justin
 
Back
Top