Subject Re: Fwd: Lookup Query keylinks problem
Author Helen Borrie
At 11:11 PM 29/03/2003 +0000, you wrote:
>--- In, "Marco Menardi" <mmenaz@l...> wrote:
>I've two tables, each that has records that must be distinguished by
>fiscal_year, and that are cloned every fiscal year, so the unique ID
>is in the form:
>2002 ABC
>2002 ADS
>2003 ABC
>2003 ADS
>well, in table A I have a field that has a lookup in table B, the
>lookup query.
>I've set a master-detail relation on the fiscal year, so in the B
>(lookup table) I've only the records of the same fiscal year of table
>The problem is that the B unique key is FISCAL_YEAR + CODE, so in the
>B table (lookup) I've to set KeyLinks in the form of:
>it works good but when I cancel a relation pressing CANC in the
>TIB_LookupCombo, of course A.FISCAL_YEAR and A.LKP_CODE are blanked,
>but A.FISCAL_YEAR is part of the primary key of A table, so I can't
>so I need:
>a) specify B.FISCAL_YEAR and B.CODE in keylinks of the lookup table
>b) don't specify B.CODE=A.LKP_CODE in the lookup table
>but this keylink:
>does not work :( (I've a lookup list, but the lookup field remains
>always empty)
>how can I do?
>Marco Menardi
>--- End forwarded message ---

Your problem stems from the fact that you are trying to implement a 1:1
master-detail relationship as a keysource-lookup and trying to make it work
both ways. K/L is exactly the reverse of M/D so you are looking at a
circular relationship here.

For K/L you must have:
-- a non-unique polling key in the parent (keysource) set
-- a unique responding key (keylinks) in the detail set
You use the K/L relationship to *write* a value from the lookup dataset to
the polling key

For M/D you must have:
-- a unique primary key in the parent (master) set
-- a unique or non-unique responding key (masterlinks) in the detail set
You use the M/D relationship to *select* a value for the foreign key of the
detail dataset.

You need to choose which you need (I think it is M/D) and implement it
accordingly. In short, K/L can't implement a master/detail relationship.