Subject Re: [IBO] Lookup Fields
Author Helen Borrie
At 04:45 AM 26/01/2005 +0000, you wrote:


>Hi,
>
>I have two datasets, the mainset defined as
>
>SELECT SOCIALSECURITY
> , DATEOPENED
> , RETAINERREMAINING
> , HOURSASSIGNED
> , CERTNAME
> , (SELECT CERTDESC FROM CERTIFICATION WHERE
>WORKINGDOCKET.CERTNAME=CERTIFICATION.CERTNAME) AS CERTDESC
>FROM WORKINGDOCKET
>
>and the lookupset
>
>SELECT * FROM CERTIFICATION
>ORDER BY CERTNAME
>
>Keylinks: CERTNAME=CERTNAME
>KeyDesclinks : CERTDESC=CERTDESC
>
>Everything works as expected except for one thing. When I change the
>underlying dataset (referred to as lookupset here) and then edit a
>record in the mainset, the description field (CERTDESC) does not
>update until I change the lookup dropdown and change it back, OR
>disconnect and reconnect the dataset.
>
>So the question is, how do I make the keylink fields update
>automatically when the underlying dataset is changed? I'm probably
>just missing a property somewhere.

Assuming you have two distinct datasets, each with its KeyLinks and
KeyDescLinks properties set, write a procedure that can be used for both sets:

procedure MyDM.SwapLookups(OldSet, NewSet, MainSet: TIB_Query);
begin
OldSet.Close;
OldSet.KeySource := nil;
NewSet.KeySource := dsMainSet;
NewSet.Open;
MainSet.Refresh;
end;

Helen