Subject Re: [IBO] KeyLiknks
Author Helen Borrie
At 09:03 AM 10/10/2007, you wrote:
>Dear Group,
>just a quick question about Keylinks, to understand if i'm making
>something faulty or not.
>
>While using a Keylink between two IB_Query (IB_Query1 Master
>and IB_Query2 Keylinked to IB_Query1) , the IB_Query2 is fetching
>the database taking a long time to get the record the first time is
>fired from IB_Query1, less while scrolling, but sometimes again is
>fetching the database. (Seems the first time is reading all the
>table like a locate, even is not checked AutoFetchAll).
>
>While instead not linking together, but using a simply Query with
>Parambyname called after scrolling IB_Query1, IB_Query2 is getting
>the record on he fly.
>
>Thanks for giving me some info on how to use correctly Keylink,
>since i'm sure i'm not using correctly.

You are not using it correctly. For a master-detail link, you use
the MasterSource and Masterlinks (or MasterParamLinks) properties to
link the foreign key of the detail set to the primary (or otherwise
unique) key of the master set.

All datasets should have Keylinks specifying their unique
fields. For simple queries, you can set KeylinksAutoDefine to let
IBO find the key field(s) from the table's metadata. For non-simple
sets, you must define the Keylinks explicitly, according to the
metadata underlying the set.

Keylinks has another usage. This is the one that you are using
incorrectly here.

You can optionally define a lookup relationship between a special
type of set (a lookup set) and another set. The relationship is
defined by setting the Keysource property on the lookup set, to point
to the set that wants to do a lookup from a non-unique "lookup
field". The relationship between the lookup set and this "lookup
field" is defined by Keylinks (in the lookup set) of the form

MyUniqueKeyField=KeySourceSet.HisLookupField

A set can not act as both a detail set in a M/D relationship AND a
lookup set in a KeySource/Lookup relationship.

The KeySource/Lookup relationship is used to enable you to embed a
TIB_LookupCombo control in an IB_Grid containing the records of the
Keysource set.

You will find examples in the Tech Info sheets about using IBO native controls.

Helen