Subject Re: [IBO] Master Detail Structure with IBOQery
Author Helen Borrie (TeamIBO)
At 01:37 PM 28-05-02 -0300, you wrote:

>Hi List!!
>
>Win98/Delphi6/IBO4Hc/FIB <--- Firebird?
>
>I´m trying to do a master detail structure with TIBOQuery for a QuickRep
>report exactly the same way I was doing with TQueries (declaring a
>paremeter on the child Query and setting the datasource propertie of the
>child query to the datasouce of the master query), but it´s not working
>fine, it´s seems like the child Query is not scrolling correctly with the
>master Query, and if I call the First method of the child table it goes
>really to first record and not the first record of the filtered ones by
>the master Query.

TDataset has two ways to form master-detail relationships between two queries:

1. Link the detail to the master through the Datasource property of the
detail query (link the detail's Datasource property to the TDatasource
object that points to the master query). This method is possible only if
there is a perfect match of fieldname(s) and types between the detail set
and the KeyLinks of the master set. In this case, don't use parameters -
TDataset does that itself. Here's the SQL for the detail query in this case:

select field1, field2, field 3, ....
from DetTable

--- or ---

2. If 1) isn't possible, then form the detail set by passing the
master-linking parameter in the AfterScroll event of the master query and
---don't--- set a Datasource property on the detail set:

Here's the detail query:

select field1, field2, field 3, ....
from DetTable
where field1 = :field1

In the master set's AfterScroll event pick up the master's KeyLinks and
apply them to the detail set:

DetailSet.ParamByName('field1').AsInteger :=
MasterSet.FieldByName('PKField').AsInteger ;

You should never need to call First() on the detail set. If you need to
test for existence of a detail set, use the IsEmpty property. But perhaps
I should leave you to explain why you need to call First(). :-)

>There´s any other configurations to this functionality to work fine with TIBO?

I like to create my datasets for QuickReport using TIB_Query objects, then
pass my data specs through to TIBOQuery objects using
AssignSQLWithSearch(). That's because I prefer to work with native
IBO. If you are working entirely with TIBO* components, there's probably
not much value in this approach for you.

regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com