Subject Re: [IBO] Same table Lookups
Author s.beames@mailbox.gu.edu.au
Thanks Helen & Geoff,
I've worked through both your replies and got it working now!
Please see below (*) for minor change needed to the solution (for
anyone-else's benefit).

----- Original Message -----
From: "Helen Borrie" <helebor@...>
To: <IBObjects@yahoogroups.com>
Sent: Friday, March 09, 2001 4:50 PM
Subject: Re: [IBO] Same table Lookups

> 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

(*) Had to change this to CLIENTS.CLIENTNAME=SUPERVISOR_NAME, or
CLIENTNAME=SUPERVISOR_NAME (as per Geoff's reply), to avoid an error
message of "FieldName: CLIENTS.SUPERVISOR_NAME not found."

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

Many thanks to you both. I think I finally have an idea of what
KeyDescLinks really does,
Steve