Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update tables based on selection in ComboBox

Status
Not open for further replies.

dchaff

Programmer
Feb 27, 2002
9
US
I have a combo box that has 2 columns - an identifier and a description. The control is bound to the identified field. Once the user selects the correct option in the combobox, it will update the field in the table. I also want to be able to update the description field in the table at the same time.
I know I can use the AfterUpdate procedure and know that that the description field is the first column of a query I use to fill the combo box (cmbDistb.Column(0)), but cannot figure out the right code to update the field in the table.
 
Since the combo box already displays the value (rather than the ID), place a non-visible control on your form that is bound to the text field in your source table. Let's call that control me.descr.

Then include in your AfterUpdate code the following statement:

me.descr = cmbDistb.Column(0)

I do have a question: since you apparently have a lookup table for the IDs and descriptions, why duplicate the text in the other table? The problem is that if the text ever gets changed in the lookup table (where you are getting your data from for the combo box), then your other table will have the wrong (or older) descriptions? By keeping the description in both tables you are losing the power of a relational database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top