Filtering Master Detail
I am attempting to convert an old ACE Report to RB. The report contains
approximately 20 opportunities for master/detail relationships. With ACE
Reporter, I was able to circumvent Delphi's slow linked query issue by
closing/changing parameter values/opening detail queries via code in a
BeforePrint event of the master.
I am struggling to find a similar event in RB to accomplish the same thing.
In reviewing the example in MagicMasterDetail.zip, I find there are no
filters on any of the queries. Naturally, that is not reality, I do not
want to retrieve all records in my detail tables to only print a select few.
With so many master/detail relationships, I also do not care to code filters
into all of my detail queries, as those filters would be subject to user
criteria from our report selection options.
Can you help.
Thanks for your time.
approximately 20 opportunities for master/detail relationships. With ACE
Reporter, I was able to circumvent Delphi's slow linked query issue by
closing/changing parameter values/opening detail queries via code in a
BeforePrint event of the master.
I am struggling to find a similar event in RB to accomplish the same thing.
In reviewing the example in MagicMasterDetail.zip, I find there are no
filters on any of the queries. Naturally, that is not reality, I do not
want to retrieve all records in my detail tables to only print a select few.
With so many master/detail relationships, I also do not care to code filters
into all of my detail queries, as those filters would be subject to user
criteria from our report selection options.
Can you help.
Thanks for your time.
This discussion has been closed.
Comments
procedure TfrmManualMasterDetail.ppDetailBand1BeforePrint(Sender: TObject);
begin
qryDetail.Close;
qryDetail.Params[0].AsFloat := qryMaster.FieldByName('CustNo').AsFloat;
qryDetail.Open;
end;
http://www.digital-metaphors.com/tips/ManualMasterDetail.zip
Otherwise, to display the detail records then you have to set the
MasterFieldLinks and MasterDatapipeline properties as shown in the
MagicMasterDetail demo. This tells the report engine what detail records to
print in the subreport from the large single detail dataset. This is the
fastest way to print master detail reports.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
changed the Report.PassSetting to psOnePass. What is the significance of
this property? The Help file merely states the obvious.
Thanks.
generated in the second pass, the entire page count is known. Observe a page
set system variable in a two pass report. It will have Page 1 of 45 on the
first page of a two pass report, while in a one pass report, it will say
Page 1 of 1, because the report has only moved through the dataset,
paginating for one page. Pagination is determined, but no output page
objects are generated in the first pass. Page objects are only created in
the second pass of a two pass report. A two pass report merely provides a
mechanism to get information about the report, which can only be determined
once the dataset has been traversed in its entirety.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
can only see one page of the report, pages 2+ are blank. When I set the
PassSetting to two pass, the report builds thousands of pages before I
cancel it, when I then attempt to see page 2, thousands of pages are again
built. I am experiencing the same behavior with my report.
Please help.
Thanks.
was. To me, the manual linking demo is too slow and Delphi query parameter
linking should not be used. I reread your initial post and your goal is to
have fast data traversal fo rhte detail datasets. When you change the query
params, it has to refire the detail query to get the latest detail dataset.
You should use a single detail query which returns all records for all
details, ordered by the master and the master's order by fields. You'll also
have to tell the report engine that you have created a special datset for it
by setting the detail datapipeline's MasterDataPipeline and MasterFieldLinks
properties. This is a much faster way to generate the report and work
around Delphi's slow query linking. Here is an example:
http://www.digital-metaphors.com/tips/MagicMasterDetail.zip
---------------------------------------------------------
Tech Tip: Define Master/Detail DataPipeline Links in Code
---------------------------------------------------------
Defining a Master/Detail relationship for a DataPipeline
requires that the detail pipeline have the
following properties defined:
1. MasterDataPipeline
2. MasterFieldLinks
At Delphi design-time you can use the object inspector
and the DataPipeline's FieldLinks editor to define
the master/detail relationship.
The following example illustrates how to define the
master/detail relationship dynamically at run-time.
var
lFieldLink: TppMasterFieldLink;
begin
{define the master/detail pipeline relationship}
plDetail.MasterDataPipeline := plMaster;
{create a new field link }
lFieldLink := TppMasterFieldLink.Create(nil);
lFieldLink.Parent := plDetail;
{assign the detail field name}
lFieldLink.DetailFieldName := 'CustNo';
{assign the master field name}
lFieldLink.MasterFieldName := 'CustNo';
end;
Note: The DataPipeline linking requires the records in the detail dataset to
be ordered by the linking fields. In the above example, the detail data must
be ordered by CustNo.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com