Subject Re: [IBO] Selective lookup
Author s.beames@mailbox.gu.edu.au
Thanks Svein & Helen,

> > is it possible to restrict the records displayed in a
> >TIB_LookupCombo based on a relationship defined in a third table?

I've just gotten it to work, using a Master-Detail embedded Lookup
Combo approach.

My LookUp SQL is:
SELECT ACCNT_ID (from ACCNTHLDRS_ACCNTS)
, ACCNTHLDR "
, ACCOUNT (from ACCOUNTS)
, SPEEDTYPE "
, CLASS "
FROM ACCNTHLDRS_ACCNTS
JOIN ACCOUNTS ON ACCOUNTS.ACCNT_ID=ACCNTHLDRS_ACCNTS.ACCNT_ID

KeySource is AccntsUsedSrc,
KeyLinks is ACCNT_ID=ACCNTSUSED.ACCNT_ID,
MasterSource is AccntsUsedSrc,
MasterLinks is: ACCNTHLDR=ACCNTSUSED.ACCNTHLDR

No other stuff necessary, except for a AccntsUsedQry->Refresh() call
when the LUCB's close to update the grid!

My 3 lookup combo's all display all three fields, but I don't mind
this at all, since the choices are all linked together anyway.

Can you see any gotcha's I'm likely to face down the track?

> Don't try to use SQLWhereItems to limit the dataset, since it would
only be applied when the statement is prepared. You would have to
unprepare and reprepare the dataset explicitly on every scroll in
order to fire OnPrepareSQL, which isn't what you want. Use a
parameter instead.

Thanks, I wasn't aware of this. I assumed that SQLWhereItems would
have been using the current field values as parameters when changing
records. (or have I misunderstood?)

Cheers for now,
Steve