Subject RE: [IBO] TIB_LookupCombo - Join Tables - too ambitious??
Author Helen Borrie
At 08:28 AM 12-09-02 +0200, you wrote:
>Hi,
>
>My intention is to allow a user to add to the COVEREDMEM table from within a
>TIB_Grid. when the user enters an 'ID' in the Person's ID column, the
>associated TIB_LookupCombo control must drop down and do an incremental
>search for this ID(not PersonId - which is a gen value). If the value is
>matched, and the user... from here I believe I can handle the various
>scenarios. My problem is the incremental searching. It does not work for
>INSERTING. It works for EDITING! I believe it has to do with the
>KeyDescLinks.

Yup. They are totally wrong.

>I get the TIB_LookupCombo to work out of the grid. Anyway,
>here are the settings:-
>
>
>LookupDataset:
>PERSON(SQL)
>------
>SELECT PERSONID
> , FIRSTNAME
> , SURNAME
> , ID
> , TitleId
> , Initials
>
>FROM PERSON
>
>KeyLinks -> Person.PersonId=CoveredMem.PersonId
>KeyDescLinks -> Person.ID=id <----- WRONG

KeyDescLinks -> PERSONID=LOOKUP_DESC

>OrderingItems -> ID=ID
>OrderingLinks -> ID=1
>KeySource -> dsCoveredFamMem
>

[....]

> ,(SELECT ID
> FROM PERSON
> WHERE COVEREDMEM.PERSONID = PERSON.PERSONID)
> AS LOOKUP_ID { I believe this is needed for the KeyDescLinks }

No, you have this wrong. You don't subselect the ID field, but the output
value that will appear in place of the ID. The purpose of KeyDescLinks is
to match up the field(s) from the lookup table that appear in the dropdown
of the lookupcombo with the output that the user sees.

i.e. Keylinks matches up the lookup key of the parent table with the PK of
the table upon which you are doing the lookup

KeyDescLinks matches up the associated Desc(ription) field with the
description that is delivered by the lookup table.

So this subselect needs to correspond to the SQL for the lookup dataset
currently :

SELECT PERSONID
, FIRSTNAME
, SURNAME
, ID
, TitleId
, Initials
FROM PERSON

...and the subselect would be something like the following and needing to
be aliased because of the join:

....
,(SELECT PERSON2.SURNAME||', '||PERSON2.TITLEDID||' '||PERSON2.FIRSTNAME|
FROM PERSON PERSON2
WHERE COVEREDMEM.PERSONID = PERSON2.PERSONID)
AS LOOKUP_DESC

> FROM COVEREDMEM
>
> JOIN PERSON
> ON (PERSON.PERSONID = COVEREDMEM.PERSONID)

....

Helen