Combo Box not displaying data.


M

mrphpman

I have a Combo Box that is intended to display one column from a query:
CategoryName, based on a RowSource statement and another column from the
query: CategoryID, is to be bound to a numeric field in the table: CategoryID.

When a selection is made from the drop-down list, the box does not display
any data.
The RowSource statement selects 3 columns from the query:
SELECT [Categories Query].[CategoryName], [Categories Query].[CategoryCode],
[Categories Query].[CategoryID] FROM [Categories Query];

The ColoumnCount is set to 1 and the BoundColumn is set to 3. Only when I
change the ColumnCount to 2 does the box display any data and the bound
column is saved to the CategoryID field. This will display 2 columns in the
Combo Box, which is not what I want.

I have another Combo Box that displays a column from another query and saves
the bound column to it's respective field in the table. The settings are
identical to the other Combo Box and it works fine. Does anyone know why this
is?
 
Ad

Advertisements

K

Klatuu

You actually answered your own question.
The RowSource statement selects 3 columns
Only when I change the ColumnCount to 2 does the box display any data

Not gonna work that way. The Column Count has to be as many columns as
there are in the query. To hide or show columns in the dropdown, you use the
Column Widths property.

Since you can do that, I would suggest you reorder your columns. It makes
life much easier if you always have the bound column as 1. For example, you
cant use
Forms!MyFormName!MyCombo.Column(2) in a query criteria. It will complain
that it can't find the function.

So do your query like this:

SELECT CategoryID, CategoryName, CategoryCode, FROM [Categories Query];

Make your Bound Column 1;

Set your ColumnWidths 0";2";0"
That will hide CategoryID and CategoryCode and the user will see
CategoryName. It 2" is too wide or narrow, change it.
Now, note that when you are addressing combos by column, the column index
starts with 0.
 
F

fredg

I have a Combo Box that is intended to display one column from a query:
CategoryName, based on a RowSource statement and another column from the
query: CategoryID, is to be bound to a numeric field in the table: CategoryID.

When a selection is made from the drop-down list, the box does not display
any data.
The RowSource statement selects 3 columns from the query:
SELECT [Categories Query].[CategoryName], [Categories Query].[CategoryCode],
[Categories Query].[CategoryID] FROM [Categories Query];

The ColoumnCount is set to 1 and the BoundColumn is set to 3. Only when I
change the ColumnCount to 2 does the box display any data and the bound
column is saved to the CategoryID field. This will display 2 columns in the
Combo Box, which is not what I want.

I have another Combo Box that displays a column from another query and saves
the bound column to it's respective field in the table. The settings are
identical to the other Combo Box and it works fine. Does anyone know why this
is?

Why do you have the combo row source returning 3 columns but you have
the column count set to 1 or 2? If you have the combo return 3
columns, set the column count to 3.
You can set the Bound column to 3 if that is the column you want to be
bound to the table field.
Then set the Column Width's property to whatever widths you wish.
As an example, set the Column Width to
1";1";0"
to display, while in drop-down, the CategoryName column and the
CategoryCode column hiding the 3rd column (the bound one). Note: Only
the first column, the CategoryName, will display after you have made a
selection.
 
Ad

Advertisements

M

mrphpman

Thank you for responding Fred but in the meantime Dave had given me advice
which I followed and it had my Combo Box working just fine.

I hadn't realized that ColumnCount pertained to the # of columns the query
returned. I thought it meant the # of columns I want displayed in the Combo
Box. That's why I originally had it set to 1. Thank again for the advice -
you can tell I'm new to this!

fredg said:
I have a Combo Box that is intended to display one column from a query:
CategoryName, based on a RowSource statement and another column from the
query: CategoryID, is to be bound to a numeric field in the table: CategoryID.

When a selection is made from the drop-down list, the box does not display
any data.
The RowSource statement selects 3 columns from the query:
SELECT [Categories Query].[CategoryName], [Categories Query].[CategoryCode],
[Categories Query].[CategoryID] FROM [Categories Query];

The ColoumnCount is set to 1 and the BoundColumn is set to 3. Only when I
change the ColumnCount to 2 does the box display any data and the bound
column is saved to the CategoryID field. This will display 2 columns in the
Combo Box, which is not what I want.

I have another Combo Box that displays a column from another query and saves
the bound column to it's respective field in the table. The settings are
identical to the other Combo Box and it works fine. Does anyone know why this
is?

Why do you have the combo row source returning 3 columns but you have
the column count set to 1 or 2? If you have the combo return 3
columns, set the column count to 3.
You can set the Bound column to 3 if that is the column you want to be
bound to the table field.
Then set the Column Width's property to whatever widths you wish.
As an example, set the Column Width to
1";1";0"
to display, while in drop-down, the CategoryName column and the
CategoryCode column hiding the 3rd column (the bound one). Note: Only
the first column, the CategoryName, will display after you have made a
selection.
 

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