Combo box: display text field, but store ID field to table

RapidFireGT

New member
Local time
Today, 05:47
Joined
Dec 5, 2011
Messages
6
[SOLVED] Combo box: display text field, but store ID field to table

My form is for adding a new product to the database. The form asks which "Club" the product is associated with. I want to create a combo box where the user can select the name of the club, and then the form will store the club's associated ID into the product table.

I've Googled how to do this, and the common answer appears to be something along the lines of:
It sounds like you might be asking how to display something in the dropdown other than the ID while keeping the ID as the returned data from the dropdown. If that's the case set the Bound Column to the ID field (usually 1) and (assuming the name field is next) set the Column Count to be 2 and the Column Widths to be 0";1" or 0";[whatever width you need].
Source - StackOverflow (can't post link, sorry :rolleyes:)

For whatever reason, this isn't working for me. I create the query in the Row source property (Fig. 1), I set up the column properties for the combo box (Fig. 2), and the combo box even displays properly in the form (Fig. 3); however, when I go back to the underlying table, all the values are the text values and not the associated IDs (Fig. 4).

Please see the attached image for all four Figures listed above.

SOLVED by Peter46 over at UtterAccess

Peter46 said:
"when I go back to the underlying table, all the values are the text values "

No they are not.
The reason you see the text values is because you are using a lookup field and that's just how lookup fields work.
They display the looked up value not the stored value.

Many developers do not use lookup fields for just this reason - they give a quite misleading impression of what is going on and can lead to problems in sorting, searching and exporting.
My advice would be to take a copy of your database and then remove the lookup from the table field (just change the display control to textbox) and build the combo box in your form instead.
Then the advice you have quoted will work as you expect.

So it was doing exactly what I wanted.

I took his suggestion for creating the combo box on the form instead and it works perfect now. Thank you, Peter46
 

Attachments

  • ComboBoxProblem.jpg
    ComboBoxProblem.jpg
    95.9 KB · Views: 1,700
Last edited:

Users who are viewing this thread

Back
Top Bottom