Combobox & Composite Primary Keys

G

Guest

How can I put a combobox on a form where the table from which the combobox
choices are drawn has a composite primary key?

Comboboxes only allow you to store one value, but my TransactionDetails
table has OrderID/ProductID as the unique identifier for each record in the
table. That's two values.

Many thanks
VT
 
D

Douglas J. Steele

Combo boxes only allow you to bind one value, but they can contain multiple
values.

In the AfterUpdate event of the combo box, you can get the values from other
columns of the selected entry by referring to the Column collection.

Private Sub MyCombo_AfterUpdate

Me.Textbox1 = Me.MyCombo.Column(1)
Me.Textbox2 = Me.MyCombo.Column(2)

End Sub

will put the content of the 2nd column of the selected row into Textbox1,
and the content of the 3rd column of the selected row into Textbox2. (The
Column collection starts numbering at 0)
 

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