Subject Re: [IBO] KeyLinks, Master-Detail
Author Paul Vinkenoog
Hello Gediminas,

> have a problem again and need your advice. Tables structure:
> Ages AgeClasses Classes Event Programs
> Age_ID AgeClass_ID Class_ID Event_ID Program_ID
> Name Class_ID Name AgeClass_ID

> I need to fill Programs table: at first I choose Age & get Classes,
> which belongs to chosen age (master-detail relation). Then such
> Age-Class relation's AgeClass_ID save to Programs table
> (keylink-lookup relation). But instead of viewing ID want to see
> Age.Name-Class.Name description (user friendly view)

But you Master-Details relations work correctly? Can you tell us
exactly between which tables you have MD-relations? As far as I can
see, candidates are:

Classes (M) - AgeClasses (D)
AgeClasses (M) - Programs (D)

Do I understand correctly that AgeClasses doen't have a field Age_ID?

As for KeySource-Lookup: if you want a lookup on e.g. ClassName in
AgeClasses, first you have to make sure that your query contains a
classname field, like this:

select AgeClass_ID
, Class_ID
, ( select Name from Classes C where C.Class_ID = AC.Class_ID )
as ClassName
from AgeClasses AC

Then you set up another query - the Lookup query:

select Class_ID
, Name
from Classes

Set the property KeySource of this Lookup query to the DataSource of
the AgeClasses query.

Set the KeyLinks of the LU query like this:
Class_ID=AgeClasses.Class_ID

Set the KeyDescLinks of the LU query like this:
Name=ClassName

Now you can use an IB_LookupCombo or IB_LookupList on your form. Hide
the ID fields so as not to confuse your users.

Please also look back at my posting from last month, where I gave you
an extensive example on how to set up M-D and KS-LU relations.


Greetings,
Paul Vinkenoog