Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The combo Box doesn't show both column values?

Status
Not open for further replies.

VBUser77

MIS
Jan 19, 2005
95
0
0
US
I have a combo box which shows me two columns when I click on the little side button but once I make my selection it only shows me the first column.

I see all of this when I click the right scroll button on the combo box.

1100 Fix
1200 Play
1300 King

But Once I make my selection (for example: 1200), it only shows me 1200 and not 1200 Play. Any ideas how to get around it.

Thanks a lot in advance.

Jay
 
The combo will only display one column. To "cheat" a little, use concatenation in the rowsource. But ensure the first column (make it hidden) contains only the primary key;

[tt]select PK, PK & " " & Description from yourtable where...[/tt]

Roy-Vidar
 
This the standard behaviour of the ComboBox object.
Take a look at the BoundColumn, ColumnWidths and ControlSource properties of this object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The value that shows is represtative of the "bound" column; the column whose value is actually being stored. This is typically the key field. The other fields are simply there to help distinguish one key value from another while selecting.

You cannot get "around" this, but whether or not you can get somehow have all fields "display" is predicated upon where the combo box data is coming from. Is it coming from the underlying data source that the form is attached to, another external table, or an underlying query?

 
If I may expand a little, on what has already been said.


1st, concatenate the 2 fields into one..

cboChoice.RowSource = SELECT txtID, txtNumber & ', ' & txtName As Choice FROM tbl...

cboChoice.ColumnWidths = 0in;1.5in

2nd, (I do this a lot), keep combo as is, but enter selection in an adjacent textbox(the cboBox width, is only the size of the arrow), then use the column properties to concatenate the results into the adjacent textbox.

txtSelection = cboChoice.Column(1) & ", " & cboChoice.Column(2)

3rd, you may consider a ListBox?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top