This tutorial describes how to create a master-detail report with hierarchically linked data using the Detail Report band. Master-Detail Report (Subreports).
The topic consists of the following sections.
This document section describes how to create a new report and bind it to a data source containing a master-detail relationship between instances.
Create a new report by clicking New in the Designer's menu.
To create a new data source, invoke the Designer's menu once again and click Add SQL Data Source.
The first page of the invoked SQL Data Source Wizard allows you to select a data connection that provides necessary information to connect to a database.
Click Next to proceed to the next wizard page.
On the following page, you can choose which tables, views and/or stored procedures from your data source to display in the report. To create a master-detail report, select two or more tables and click Next.
On the next wizard page, define a master-detail relationship between queries by specifying their corresponding keys. To do this, click the plus button next to the master query, choose the detail query to add a new relationship and specify the relationship condition as shown in the following image.
Click Finish to complete the wizard.
The hierarchy of the created data source will be reflected in the Field List.
To construct the layout of a master-detail report, do the following.
Select a report and switch to the Properties Panel. Actions category and click Insert Detail Report Band.
Set the Data Member property of the master report to the master query (in this example, it is the Categories query).
To generate the detail report properly, set its Data Member property to the name of the master-detail relationship (e.g., CategoriesProducts in this tutorial).
Then, drop the required data fields from the Field List onto the report bands. For the detail report, take fields from the master-detail relationship (the CategoriesProducts section).
The master-detail report is now ready. Switch your report to the Preview mode and view the result.