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

Empty Detail-band subreport affects next one

edited March 2005 in Subreports
Hi,

I'm using ReportBuilder 9.0 for Delphi 6. I've run across an unexpected
behavior whereby a child subreport without data affects the printing
behavior of the next, unrelated child subreport. It appears as though
the first record in the next subreport is lost. Specifically, its first
group header has no group value, and detail DBText controls are blank,
and variables are zeroed. However, its group footer recovers the
group value.

I implemented a report simulating master/detail behavior
manually by querying for child details upon the master pipeline's
OnRecordPositionChange(). For concreteness, the "master" data are
basically account numbers and "child" data are per-account, categorized
budget summaries. The master report has no printing bands apart from
the detail band with a section subreport that provides all of the
actual content.

In case this is relevant: To optimize report generation speed over
hundreds of accounts, I separately compute the child detail table as
a standalone TClientDataSet and cache it. In the master pipeline's
OnRecordPositionChange() I restore the cached result to the child pipeline
in the following manner, where "pplChild" is the child pipeline and
"dscChild" is its DataSource:

pplChild.Close;
dscChild.DataSet := cachedDataset;
pplChild.Open;

When a child detail table has no records, I still print the subreport. As
there are no categories, the category header is blank and the detail band
is (as documented) printed with blank DBText and zero-valued ppVariable
elements. The group footer, as expected, reflects no detected group value.

The strange part happens when the master pipeline moves to the next
account when the next has detail data. Its first group's header band
and only detail band appear just as in the prior [no-data] subreport
instance-- blank and zeroed. (Note that the first group often naturally
has only one detail record.) However, the group footer seems to have
picked up the group value. The remainder of the subreport, i.e. other
groups and the summary band, are normal except that totals in the summary
band are incorrect reflecting the missing detail record.

If I artifically force a first record to appear by adding it twice to the
detail table, it reveals something new. The "nameless" first group still
appears exactly as before and consumes the first record, but then a "real"
first group suddenly appears normally below it to reflect the artificial
record.

Again, this only happens following a "blank" subreport; otherwise
subreports print as expected. I've also observed that the problem
goes away when I conditionally hide the main report's detail band (and
hence the subreport) upon computing a blank child detail table. It is
as though the child pipeline or subreport preserves special "blank report"
state that is not cleared until after traversing the first detail record
for the next subreport.

I wonder if I am forgetting to do something, or misusing the child pipeline
by un/plugging its datasets? Otherwise, how do I recover that first record
and suppress the phantom first group?

Thank you for your help, and for a very useful product,

Jonathan Marks

Comments

  • edited March 2005
    Hi Jonathan,

    If you remove the optmization from your app (i.e. don't close your dataset
    and cache the data in a client dataset), are you still able to create this
    behavior? This could be a timing issue having to do with when you are
    creating this separate dataset. If you still see this behavior, please put
    together a simple example I can run on my machine that recreates this
    behavor and send it in .zip format to support@digital-metaphors.com and I'll
    take a look at it for you.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.