Combo box with 3 part foreign key

G

Guest

I have a table that has a 3 part foreign key to a look up table. How do I
implement a combo box that looks up field1, field2, field3 and descriptive
name in the lookup table and populates field1, field2 and field3 in the
target table?
Thank you. bob 4
 
J

John W. Vinson

I have a table that has a 3 part foreign key to a look up table. How do I
implement a combo box that looks up field1, field2, field3 and descriptive
name in the lookup table and populates field1, field2 and field3 in the
target table?
Thank you. bob 4

That will take some code, since a combo box can have only one bound column.
The key issue I'd worry about is: does the description field (the first
visible field in your combo, presumably) have any duplicates? I.e. if the user
picks a description, can you count on that bringing up a specific triplet of
values?

If so, just include all four fields in the combo's rowsource, and use the
AfterUpdate event of the combo to push the values into bound controls:

Private Sub cboMyCombo_AfterUpdate()
Me!txtField1 = cboMyCombo.Column(1)
Me!txtField2 = cboMyCombo.Column(2)
Me!txtField3 = cboMyCombo.Column(3)
End Sub

where column(0) is the first/visible/description field. The combo should be
unbound (nothing in its control source), and you'll need code to show the
value for the current record in the form's Current event.

John W. Vinson [MVP]
 
G

Guest

Thanks, John. I can do that. bob 4

John W. Vinson said:
That will take some code, since a combo box can have only one bound column.
The key issue I'd worry about is: does the description field (the first
visible field in your combo, presumably) have any duplicates? I.e. if the user
picks a description, can you count on that bringing up a specific triplet of
values?

If so, just include all four fields in the combo's rowsource, and use the
AfterUpdate event of the combo to push the values into bound controls:

Private Sub cboMyCombo_AfterUpdate()
Me!txtField1 = cboMyCombo.Column(1)
Me!txtField2 = cboMyCombo.Column(2)
Me!txtField3 = cboMyCombo.Column(3)
End Sub

where column(0) is the first/visible/description field. The combo should be
unbound (nothing in its control source), and you'll need code to show the
value for the current record in the form's Current event.

John W. Vinson [MVP]
 

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