Combo Box/SQL statement

M

Monty

I have a combo box whose Row Source Type is table/query and Row Source
is "SELECT DISTINCT [Package Name] from Packages ORDER BY [Package
Name];". I can see the values when I run that SQL statement as a
query, but nothing shows up when I run it as a function of the form
(i.e., the form opens up, the SQL statement runs, but nothing shows up
in the combo box). I mean literally, nothing shows up, although I can
see there are the three place holders in the list I'm expecting, but
no text.

I'm wondering how much effect the Bound Column property has on this,
and frankly, from the help pages, I can't understand what it's
supposed to indicate. The Bound Column is currently 2--that's the
value Access put into it-- but I've tried it with 0 through 3 to no
effect.

What am I missing here?
 
G

Guest

The BoundColumn property of a combo or list box is the column from which the
control takes its value when a selection is made. As in your case your SQL
statement only returns one column then it should be 1 not 2.

I also suspect that the ColumnWidths property might be incorrect. My guess
is that it is two dimensions with the first zero, which would be why you see
nothing because the first column is your one and only column, so if its width
is zero it will be hidden. Simply delete the entry for the ColumnWidths
property.

You might also find that the ColumnCount property is not 1. If so change it
to 1.

The sort of situation where you would hide the first column, set the
ColumnCount to 2 and the ColumnWidths to two dimensions of which the first is
zero, is when you want the value to be something like an arbitrary numeric ID
but you want to see the corresponding meaningful text value. Say for
instance you had a foreign key column CityID in a table, referencing the
primary key of a Cities table. A combo box bound to that column in a form
would have a RowSource:

SELECT CityID, City
FROM Cities
ORDER BY City;

Its BoundColumn property would be 1 so that the (unseen) value of the
control would be the CityID, its ColumnCount 2 as the SQL statement returns 2
columns, and its CoumnWidths something like 0cm;8cm to hide the CityID and
show just the city names.

Ken Sheridan
Stafford, England
 
M

Monty

I also suspect that the ColumnWidths property might be incorrect. My guess
is that it is two dimensions with the first zero, which would be why you see
nothing because the first column is your one and only column, so if its width
is zero it will be hidden. Simply delete the entry for the ColumnWidths
property.

You might also find that the ColumnCount property is not 1. If so change it
to 1.

That's exactly what it was, thanks!
 

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

Similar Threads

Combo box default 7
Combo Box Problem 23
Blank combo or list box 1
Combo Box 2
Cascading Dependant combo boxes 0
Combo Box Sorting and Selecting 4
Row Source for Combo Box 2
Combo Box QUESTION 5

Top