Subject Re: [IBO] Same table Lookups
Author Helen Borrie
At 11:56 AM 09-03-01 +1000, you wrote:
>Hi,
> I have a single CLIENTS table containing people's names & details, including a nullable column to
>identify another person in this table who is the current persons' supervisor.
>I was hoping to have a form for this table with a TIB_Checkbox to toggle the forms' display between
>a supervisors accounts grid OR that persons' supervisors' name in a TIB_LookupCombo. The problem I
>strike with the KeyLinks for the lookup query is trying to set
>CLIENTS.SUPERVISORNO=CLIENTS.CLIENTNO, which ain't allowed!
>What should I be doing? I didn't want to split clients & supervisors into separate tables because
>either one can raise a work request.

You need two queries...

This one for the grid:

SELECT C1.CLIENTNO, C1.OTHERFIELD1, C1.OTHERFIELD2, C1.SUPERVISORNO
(SELECT C2.CLIENTNAME FROM CLIENTS C2 WHERE C2.CLIENTNO = C1.SUPERVISORNO)
AS SUPERVISOR_NAME
FROM CLIENTS C1

and this one for the lookup table:

SELECT CLIENTNO, CLIENTNAME FROM CLIENTS

The Keylinks for the grid query will be CLIENTS.CLIENTNO.

The Keylinks for the lookup query will be
CLIENTNO = CLIENTS.SUPERVISORNO

Set the KeySource property of the lookup query to the name of the datasource that points to the grid query, i.e. the lookup's KeySource will be the same as the grid's Datasource.

Set the lookup query's KeyDescLinks property to
CLIENTNAME = CLIENTS.SUPERVISOR_NAME

And remember to go in and set the COMPUTED property of SUPERVISOR_NAME in the grid query to True.

Cheers,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________