Home Subreports
New Blog Posts: Merging Reports - Part 1 and Part 2

Missing subreport data

edited July 2007 in Subreports
I have a report that was relatively easy to create in QuickReports that I am
simply unable to develop in ReportBuilder 10.6 with Delphi2006

Scenario

a) Query1 selects patients and is attached to ppDBPipeline1.
Table1 that has a master-detail relationship with the Query1 and is
attached to ppDBPipeline2.
Table2 that has a master-detail relationship with the Query1 and is
attached to ppDBPipeline3

b) Report Detail band is attached to ppDBPipeline1
- detail band contains Subreport1 which is attached to ppDBPipeline 2

c) Subreport1 contains a Group Header band, a Detail band, and a Group
Footer band
- the Detail band contains Subreport2 which is attached to ppDBPipline3
- the Footer band contains summary data on the ppDBPipeline3 records.
This information is correctly calculated in the Subreport1
GroupHeaderBeforePrint event

d) Subreport2 has only a detail band.


The details bands for main report and both subreports have PrintHeight =
Dynamic and ndBlankPage = True;
Both Subreports have PrintBehavior = pbChild. Other choices did not help

The issue is that the Report prints correctly only if there is at least one
record in Subreport2. Normally this table is filtered to display records
for only the last 30 days. However, in some instances no records are
present, and the report does not print. What I would like is Subreport1 to
print and Subreport2 to be blank.

The following were unsuccessful attempts at solving the above issue:
First, I determined the date of the last record in Table2 in Subreport1
GroupHeaderBeforePrint. Then
a) in the Subreport2 DetailBandBeforePrint event Table2 was filtered for the
last 30 days. If this resulted in no records in Table2, the filter was
changed to filter with date >= the derived last record date for Table2.
This did not work, and I can not explain it.
b) as an alternative to filtering Table2, I tried defining the Subreport2
detail band as visible or not visible based on whether the record date was



Suggestions??

TIA

John Eastman

Comments

  • edited July 2007
    The solution is as follows. The principle was correct, the problem was that
    I was using the date value obtained from the table and not the pipeline
    attached to the table to evaluate the date. See below:

    var
    tempValue: TDateTime;
    begin
    tempValue := ppDBPipelineAcctItems.GetFieldValue('TransactionDate');

    // if adsTableAcctItems.FieldByName('TransactionDate').AsDateTime >=
    tempLastTransactionDate then

    if tempValue >= tempLastTransactionDate then
    begin
    ppDetailBand3.Visible := True;
    end
    else
    begin
    ppDetailBand3.Visible := False;
    end;

    John

This discussion has been closed.