About nested reports

A nested report is a report within another report.

There are two ways to create reports containing nested reports:

About creating a composite report

You can choose the Composite presentation style to create a new report that consists entirely of one or more nested reports. This type of report is called a composite report. A composite report is a container for other reports.

You can use composite reports to print more than one report on a page.

Composite report

For example, the following composite report consists of three tabular reports. One of the tabular reports includes a graph:

The sample composite report is titled Quck Reference Information. At top left, it displays a nested report of five columns called Products and Current Inventory. At top right is a nested report of four columns called Sales Representatives and Total Number of Orders. Spanning the bottom is a third report that has five columns of data at left with the title Product Sales Summary and a nested bar graph at right called Sales Summary. The Sales Summary graph plots the dollarvalues from the Product Sales Summary on the x axis against the product names from the Product Sale Summary on the y axis.

Composite report in the Design view

In the Design view, you see three boxes that represent the individual tabular reports that are included in the composite report. The only additional controls in this example are a title, date, and page number:

The header band of the Design view displays today ( ) and the title Quick Reference Information. The detail band  displays three boxes with the underlined text composite products, composite sales reps, and composite product sales. The footer band displays the expression ’ Page ’ + page (

About placing a nested report within another report

You can place one or more reports within another report. The report you place is called the nested report. You can place a nested report in any type of report except crosstab. Most of the time you will place nested reports in freeform or tabular reports.

Often, the information in the nested report depends on information in the report in which it is placed (the base report). The nested report and the base report are related to each other by some common data. The base report and the nested report have a master/detail relationship.

Freeform report with a related nested report

For example, the following freeform report lists all information about a customer and then includes a related nested report (which happens to be a tabular report). The related nested report lists every order that the customer has ever placed. The base report supplies the customer ID to the nested report, which requires a customer ID as a retrieval argument. This is an example of a master/detail relationship—one customer has many orders:

The sample report is titled Customers and Orders. At left is an area titled Customer Information that displays the customer I D, name, address, and phone information for a single customer. At right is a nested report called Order History that includes six columns of information for four orders the customer has placed, listed by Sales Order I D.

What you see in the Design view

In the Design view, you see everything in the base report plus a box that represents the related nested report:

The Design View sample shows a header band for the Customers and Orders report that includes the title Customer Information on the left and Order History on the right. In the Detail band, labels and columns display on the left for the for I D, name, address, and phone information for a customer. On the right there is only a box labeled Tabular Orders.

The difference between nested and composite reports

There are two important differences between nesting using the Composite style and nesting a report within a base report.

Data sources The composite report does not have a data source—it is just a container for nested reports. In contrast, a base report with a nested report in it has a data source. The nested report has its own data source.

Related nesting The composite report cannot be used to relate reports to each other in the database sense. One report cannot feed a value to another report, which is what happens in a master/detail report. If you want to relate reports to each other so that you can create a master/detail report, you need to place a nested report within a base report.

How retrieval works

When you preview (run) a composite report, PowerBuilder retrieves all the rows for one nested report, and then for another nested report, and so on until all retrieval is complete. Your computer must have a default printer specified, because composite reports are actually displayed in print preview mode.

When you preview (run) a report with another related report nested in it, PowerBuilder retrieves all the rows in the base report first. Then PowerBuilder retrieves the data for all nested reports related to the first row. Next, PowerBuilder retrieves data for nested reports related to the second row, and so on, until all retrieval is complete for all rows in the base report.

For information about efficiency and retrieval, see “Supplying retrieval arguments to relate a nested report to its base report”.

Limitations on nesting reports

For the most part you can nest the various types of report styles. However, limitations apply to two of them.

Crosstabs You cannot place a crosstab with retrieval arguments within another report as a related nested report. However, you can include a crosstab in a Composite report.

RichText reports You cannot nest a RichText report in any way. You cannot place a RichText report in another report, and you cannot include a RichText report in a Composite report.