Getting column 2 to display in combobox when selected


S

Spidey3721

I have a combo box with two columns showing. the first column is a number
and the second is a description of that number. I want the description to
show in the field once something is selected, but it keeps showing the
number only. The only way I've found so far is to switch the columns, which
I'd rather not do....

I thought that changing the bound column would do it, but it doesn't seem
to...
 
Ad

Advertisements

C

Cheryl Fischer

Set the Column Count to: 2
Set Column Widths to: 0";1"

Change the 1" to whatever display size you want for the value in your second
column

hth,
 
S

Spidey3721

I want both of the columns to show when I pull down on the combobox, but I
want the 2nd column to display in the field after selected...

Right now I have column count =2, so I can show both the number and the
description in the pulldown
I have the widths set for each column so I can see both, .5", 2.5"

The number field keeps showing after the selection is made - I want the
description to show WITHOUT having to switch the order of the columns (by
making the number the second column and the description the first column)
 
C

Cheryl Fischer

From the Access Help file: "In a combo box, the first visible column is
displayed in the text box portion of the control."

Therefore, if you want the second column of your combo box to be the
displayed value on your form after selection of a value, you will either
have to make the first column 0" in width or change the order in which the
columns are displayed.
 
Ad

Advertisements

Joined
Nov 26, 2013
Messages
1
Reaction score
0
Hi,
All You need to do the following ...
  1. Define a string Variable in order to be able to concatenate
  2. Normal Select Query two Columns.
  3. Execution query in a record set.
  4. Setting properties ColumnCount = 2 ; ColumnWidths=100 pt;0 pt;BoundColumn= 2
  5. As you loading ComboBox from the record set, do the follwoing ..
rs.MoveFirst
If Not rs Is Nothing Then
If Not (rs.EOF And rs.BOF) Then
With cmb1
.Clear
Do
strComboItem = rs![GroupID] & " " & rs![GroupDescription]
.AddItem ComboItem
rs.MoveNext
Loop Until rs.EOF
End With
End If
End If
P.S...
  • strComboItem is a String Variable used for Concatenation Purposes
  • cmb1 is a ComboBox
 
Ad

Advertisements

Joined
Dec 17, 2015
Messages
1
Reaction score
0
The easiest solution is making 3 columns...
Make the first and third columns the same field, but when setting the widths make the first column something super small like .001"
That way it's there and "visible" to access as the "first" column and will be shown in the box after selection, but your users will only see columns 2 and 3 in the dropdown.
 

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