How to show non-bound column in combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A simple table Product has two fields Product Number and Product Description.

Another table (say Customer table) stores Product Number.
A Customer form has a combo box whose source is the Product table.

I want the combo box to SHOW Product Description but STORE Product Number in
the Customer table.

If the bound column of the combobox is 1 then it will store Product Number
but will also show Product Number.

By 'show' I do not mean when the combo box drops down. Sure, both number and
description are shown there.
 
Set the ColumnWidths property of the combo so that the bound column is
zero-width. It will then show the other column.

Example properties of the combo:
Row Source: SELECT [ProductID], [ProductDescription] FROM Product;
Bound Column: 1
Column Count: 2
Column Widths: 0
 
Thanks Allen

I know about that technique but it does not solve my problem.

I want column 2 (Description) to show in the combo box but ProductID to be
stored in the database.

Allen Browne said:
Set the ColumnWidths property of the combo so that the bound column is
zero-width. It will then show the other column.

Example properties of the combo:
Row Source: SELECT [ProductID], [ProductDescription] FROM Product;
Bound Column: 1
Column Count: 2
Column Widths: 0
 
Thanks Allen

I know about that technique but it does not solve my problem.

I want column 2 (Description) to show in the combo box but ProductID to be
stored in the database.

I think what Allen ment to say for the column width was

0;1.5

If the bound column (which need not be the first) is of zero width it
will be stored but not shown.

John W. Vinson[MVP]
 
Thomas, the idea is to set it up so that:
- the combo has 2 columns (ProductID, and Descrip), and
- the bound column is the first (ProductID gets stored), and
- the first column is zero-width (so Access displays the 2nd one).

Even when the combo is not dropped-down, Access does not display the
zero-width column. I think that's what you are after?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
ThomasAJ said:
Thanks Allen

I know about that technique but it does not solve my problem.

I want column 2 (Description) to show in the combo box but ProductID to be
stored in the database.

Allen Browne said:
Set the ColumnWidths property of the combo so that the bound column is
zero-width. It will then show the other column.

Example properties of the combo:
Row Source: SELECT [ProductID], [ProductDescription] FROM Product;
Bound Column: 1
Column Count: 2
Column Widths: 0


ThomasAJ said:
A simple table Product has two fields Product Number and Product
Description.

Another table (say Customer table) stores Product Number.
A Customer form has a combo box whose source is the Product table.

I want the combo box to SHOW Product Description but STORE Product
Number
in
the Customer table.

If the bound column of the combobox is 1 then it will store Product
Number
but will also show Product Number.

By 'show' I do not mean when the combo box drops down. Sure, both
number
and
description are shown there.
 
Yes, that's okay too, and probably makes it more obvious what's going on.

But if the combo has just two columns and the first one is zero, Access
gives whatever space is left to the remaining column. You can therefore just
set the ColumnWidths to:
0
for this fairly common scenario.
 
Yes, that's okay too, and probably makes it more obvious what's going on.

But if the combo has just two columns and the first one is zero, Access
gives whatever space is left to the remaining column. You can therefore just
set the ColumnWidths to:
0
for this fairly common scenario.

<boing>

That's why I love these newsgroups: it's a rare day when I don't learn
*something*, and this is something I didn't know. Thanks Allen, and
sorry for jumping in!

John W. Vinson[MVP]
 
Back
Top