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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Control Source - Combination Primary Key

Status
Not open for further replies.

trScott

Technical User
Dec 13, 2004
31
0
0
US
I'm trying to use a combo box to select values for a record in a table. In addition to the primary key value and other arbitrary information, three of the required values are a Foreign Key to another table (say field A,B, and C). In the foreign table, A,B and C is the primary key value (combination of the three). How can I (if possible) use a combo box to look up a combination of A, B, and C (in the lookup table) and insert the values into the local record?

Per example, I'm using a table to store checks I've written (in regards to a tax program). A is a State Code, B is a check Type, and C is the type of entity (person, company, etc.) My lookup table uses A,B,C as a PK and then has address information for each of these unique combinations - a late fee check to FL for an Individual must be sent to this addresss.

Thanks for any help!
 
Row source:
[tt]select a, b, c, <other fields?> from yourtable order by <some field(s)>[/tt]

make as many of the fields as necessary "invisible" (column widths 0;0;0;1)

In the after update event of this unbound combo, try something like this

[tt]me.controls("txtA").value = me.controls("cboCombo").column(0)
me.controls("txtB").value = me.controls("cboCombo").column(1)
me.controls("txtC").value = me.controls("cboCombo").column(2)[/tt]

You may find a need to tweak a little to make it work as you like, you know, many will use exactly situations like this to promote fascination to surrogate keys ;-)

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top