The selected value displayed in a combobox

jbfraleigh

Registered User.
Local time
Today, 03:54
Joined
Aug 8, 2000
Messages
22
I'm sure this is simple and I'm just missing something...

I have a combo with two columns and the row source set up as a query which returns two columns.

When I click the drop-down arrow for the combo box, I get exactly what I expect.

What I want to do is initialize the combo box so that the "default" selection is displayed in the "text" or "value" section of the box. I also want to be able to update this when the user makes a selection.

I have no problems when using a list box with something like:
listbox.value = <Some Index in the listbox>

With the combo box, I've tried:
combobox.text = xxx
combobox.value = xxx
combobox.column = xxx
combobox.itemdata = xxx
combobox.listindex = xxx

The value property sort of works -- It displays the data from the first column right justified in the "text" section of the combo box. I need to have both columns displayed the way they are when the combobox is dropped down.

Any thoughts?

Thanks in advance...
 
1. When you drop down the combo's RowSource list, you can see as many columns as you want. After you make a selection, you will see ONLY one field. The first visible column.
2. Normally, the "key" field is the bound field and is hidden and only the "text" field is shown in combos. To accomplish this, select the first field (the "key" field) as the bound field and change the column widths property to 0;3". This will hide the first column since its width is 0 and display the second column as 3".
3. If the bound field is numeric, that is the value you need to provide. For example:
1 aaa
2 aba
3 ccc
4 ddd
If you want "ccc" to be selected, you need to put 3 in the value field:
Me.YourCombo = 3
 
Thanks for the response.

However, I need to be able to display both columns... Does Access by any chance have a drop-down Listbox type?


Thanks
 

Users who are viewing this thread

Back
Top Bottom