Article

From:
To:
All
Subject:
Empty Detail-band subreport affects next one
Newsgroup:
digital-metaphors.public.reportbuilder.subreports

Empty Detail-band subreport affects next one

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
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Fri, 29 Mar 2024 07:42:58 UTC
Copyright © 2009-2024
HREF Tools Corp.