Wrong column displayed in combo

J

Jonathan Blitz

I have a combo box which is defined as based on a table.
This works ok. It displays the text column and saves the index column as I
require.

However, in my VBA code I replace the rowsource with an SQL statement. When
I do this it displays the index column after a value is selected instead of
displaying the text column.

Funny thing is that I have another version of the same form which does work.
The only change I made was to the SQL statement in the VBA code.

The change was to make the statement a join.

I though that maybe the join was confusing it so I changed the SQL statement
to an extra level so that the top level is selecting from one table.

The other point is that the new SQL statement displays more than one column
whereas the previous one only displayed one.

So, what do I do to get it to display the correct column?

--
Jonathan Blitz
AnyKey Limited
Israel

"When things seem bad
Don't worry and shout
Just count up the times
Things have worked themselves out."
 
S

Scott McDaniel

Do you have multiple columns AND columnwidths specificed on the problem
control? By default, a combo only "exposed" a single column. For example, if
you wish to have 3 columns in the rowsource of your combo and expose the 2nd
and 3rd ONLY, then set you parameters to this:

..ColumnCount = 3
..ColumnWidths = 0;1;1

This would hide the first column (which is likely the Bound column, unless
you've changed that) and expose a multi-column combo showing the 2nd and 3rd
columns.
 
J

Jonathan Blitz

Seems I didn't explain correctly.

When the drop-down appears all is ok. But when a value is selected it shows
the key value instead of the string.

Example:
Column1 Key
Column2 Char
Column3 char

When I display the drop down then columns 2 and 3 are displayed (as I want).

After selecting the value the combo box shows the value in column1 instead
of that in column2.
This only happens after I change the row source via VBA. When I originally
define the combo box it does show the second column after selection.

--
Jonathan Blitz
AnyKey Limited
Israel

"When things seem bad
Don't worry and shout
Just count up the times
Things have worked themselves out."
 

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