Subject Re: [IBO] Difference between keysource and mastersource
Author Lucas Franzen
Enmitko schrieb:
> Hi!
>
> I've been trying to figure out the difference between keysource and
> mastersource.
>
> Could someone write more on this.


MasterSource:
-------------
If you setup Master-Deatil relation then the detail query should point
to the Datasource of the masterquery and you have to enter the
appropriate MasterLinks.

Example:
create table INVOICE (
INVOICE_ID INTEGER NOT NULL, /* primary key */
INVOICE_TYPE_ID INTEGER,
INVOICE_NO VARCHAR(20),
etc...
);

create table INVOICE_ITEMS (
INVOICE_ITEM_ID INTEGER NOT NULL /* primary key */
INVOICE_ID INTEGER NOT NULL /* foreign key to INVOICE */
etc...
);


So MasterQuery is:
SELECT * FROM INVOICE
WHERE ...

Your detail query is:
SELECT * FROM INVOICE_ITEMS
and you masterLink in the DetailQuery is:
INVOICE_ITEMS.INVOICE_ID=INVOICE.INVOICE_ID

So IBO will automatically show you the Items for the current selected
Invoice (NOTE: you don't have to supply a param for this as you had to
do in BDE days - this is done by IBO).

QryInvoiceDetails has to set the MasterSource property to the Datasource
of the QryInvoice then.


KeySource:
----------

If you have a lookup table then you need the KeySource.
create table INVOICE_TYPE (
INVOICE_TYPE_ID INTEGER NOT NULL, /* primary key */,
INVOICE_TYPE_TEXT VARCHAR(30),
etc...
);

If you want to enter a new Invoice and want to select the InvoiceType by
text and let IBO automatically provide the related ID in the
INVOICE_TYPE field then you can aconstruct like:

QryInvoiceType:
Select * FROM INVOICE_TYPE

Set the KeyLinks property to:
INVOICE_TYPE..INVOICE_TYPE_ID=INVOICE.INVOICE_TYPE_ID

KeySource=DataSourceINVOICE

Now you can connect a Datasource to this query and connect a
TIB_LookupCombo to this Datasource.

When you show a record of INVOICE IBO will automatically show you the
appropriate field in the TIB_LookupCombo (the one you defined in the OI
for th LUCombo).
When you insert a new record a you can just select a record in the
LUCombo and IBO will assign the appropriate value (the ID).

Hth

Luc.