Subject Nested KeyLinks and MasterLinks
Author George Hugo
Delphi6/IBO4.2HC/FB

Hi all!! Well, I´m having some problems with keylinks.

A have some tables


[Clientes]
ID_CLI
RAZAO
...

[Produtos]
ID_PROD
...
DESC_PROD
...

[Pedidos]
ID_PED
ID_CLI
....

[Itens_Ped]
ID_PED
ID_PROD
....

[Nfisc]
ID_NOTA
NUM_NOTA
...
NOTA_MAE
...
ID_CLI
...
ID_PED

[Itens_Nfisc]
ID_NOTA
ID_PROD
DESC_ITEM
...

I would like to do this relationship:

[Itens_Nfisc]
MasterLinks = ITENS_NFISC.ID_NOTA=NFISC.ID_NOTA

[Clientes]
KeyLinks = CLIENTES.ID_CLI=NFISC.ID_CLI

[Pedidos]
KeyLinks = PEDIDOS.ID_PED=NFISC.ID_PED
MasterLinks = PEDIDOS.ID_CLI=CLIENTES.ID_CLI

[Itens_Pedido]
MasteLinks = ITENS_PEDIDO.ID_PED=NFISC.ID_PED
KeyLinks = ITENS_PEDIDO.ID_PROD = ITENS_NFISC.ID_PROD
ITENS_PEDIDO.ID_PED = ???

At this point start the problem.
A wrote the SQL sentence in a IB_Query that access Itens_Nfisc

Select N.ID_PED, I.*
From Nfisc N, Itens_Nfisc I
Where I.ID_NOTA = N.ID_NOTA

KeyRelation=Itens_Nfisc

And set the KeyLinks of Itens_Pedido
KeyLinks = ITENS_PEDIDO.ID_PROD = ITENS_NFISC.ID_PROD
ITENS_PEDIDO.ID_PED = NFISC.ID_PED

But it doesn´t works fine, the TIB_LookupCombo that access the IB_Query of
Itens_Pedido doesn´t scrolls!!

I´ve created a View for the Itens_Nfisc that returns the Field
ID_PED within.

But it the problem still remains!!

Sorry for the english, I hope I´m being a little clear

Can anyone help me?

George Hugo
Member of Portuguese language Firebird Comunity