A sub report, or nested report, is a report within a report. A sub report is used when a report is too complex to be designed using just data bands and master detail relationships. The Report Designer enables a sub report to be within a sub report. This deep nesting of sub reports ac be up to six nested reports.
When a sub report object is inserted into a report design the Report Designer automatically adds a new page that is connected to the sub report. Sub reports nested within a report resembles a multi-page report in terms of design structure. The only difference is that the nested report is displayed in a specific location on the basic design page, and not after it. Aa a report with a sub report is executed, when the sub report object is encountered the report engine outputs the connected sub report page in its entirety. After that sub report output completes, the report continues with the rest of the basic design page.
Two or more sub report objects can be placed side-by-side on the same data band as in the example below:
This design enables reports where the data output of each sub report has varying lengths of rows/records, or varying heights or degree of stretching as in:
As illustrated, the report continues to output the basic design page only after the longest sub report has finished. The Vertical Alignment property can also be used to adjust Text object alignment within each sub report.
Since sub reports are placed on the basic design page, they cannot contain any of the following bands:
If any of these bands are placed on a nested report page they will not be recognized. For the same reason there is no point in changing any nested report page options, as the options of the basic report page override those of any nested pages.
When working with sub reports it is important to not place objects below the sub report without using a Child Band. If you do not use a child band for objects below a sub report, the objects created in the sub report will overlay everything placed below the sub report object on the main design page. This example below will not work as expected:
To display objects below or after a nested report, use a child band as in:
A Child Band is also used when several sub reports must be placed one below the other; use a Child Band for each sub report and chain them together, setting the Child property of Child1 to Child2, and so on.
The sub report object has a PrintOnParent property that can be useful. Usually a sub report is output as a set of bands on the basic report page and the height of the parent band containing the sub report object is not controlled by the bands in the sub report (That is, it cannot be stretched). If the sub report PrintOnParent property is set to True, either in the object inspector or the context menu, the objects in the sub report are physically printed on the band which contains the sub report object.