Designing master-detail reports

There are two ways to design master-detail reports. The first option is to use subreports. This is the only option if master and detail rows cannot be easily joined into a single rowset. If the master and detail rows can be joined into a single rowset then using nested data regions offers better performance.

Third party solutions

Got a database? Use Visual DB database form builder to build data entry forms.

Option #1: Using Subreports

When implementing master-detail using subreports, a List is used to display master rows. A subreport nested inside the List is used to display the detail rows.

Contents of the List repeat for each row in the master. Since the subreport is contained in the List, the subreport is executed for each row in the master. The master row's primary key is passed to the subreport as a report parameter. The subreport examines the report parameter, and displays detail rows that match the supplied master primary key. For more information about report parameters and subsetting data click here.

Subreport inside a List: Download sample app.

Option #2: Using nested data regions (recommended approach)

This approach offers better performance than subreports. In order to use this approach you must first join the master and detail rows into a single rowset. If this is not easy (for example, if your data is not coming from a SQL database) then use subreports instead.

A List is used to display fields from the master. Then another data region such as a Table or a List is nested in the first List to display detail rows.

The outer List must group data on the master's primary key. To do this, right-click on the List and choose Properties from the context menu. In the List Properties dialog click on Edit details group. In the Grouping and Sorting Properties dialog enter the master's primary key as the Group on Expression.

Since the List has a details group expression, contents of the List repeat for each instance of the group. Items inside each group instance can be displayed using a data region (such as a Table or another List), nested in the first List. For more information see Using Lists.

Table inside a List: Download sample app.