Create a Master-Detail Report
A report is usually called Master-Detail if it is used to display data from a hierarchical data source. There are two main approaches for creating a master-detail reports. The first approach is based upon using the Detail Report band and is useful when a data source contains an ADO.NET relation between master and detail instances within it. The second approach is to create two different report classes and incorporate the detail report into the master report as a sub-report.
These reports are useful when you want to display more than one set of detail records and you cannot achieve this using grouping.
|
- Fill in the Name and Description fields for the Advanced Report properties.
- Double-click on the Data Sets link in the Property Editor form.
- Click the plus icon to add a new Data Set called Sites from the GB_SITE table.
- Fill in the SQL Script Properties form as shown below, then click OK.
- Click the plus icon to add a new Data Set called Projects from the Projects table.
- Fill in the SQL Script Properties form as shown below, then click OK.
- Click the plus icon to add a new Data Set called Master from the Projects table.
- Fill in the SQL Script Properties form as shown below, then click OK.
The Data Sets tab will look like the following:
- Select Layout and click on the Launch Designer icon to bring up the Report Designer screen.
Note that the Field List shows the Master-Detail relationship where the Site table has been put into the Projects table as an embedded detail table in Projects_Sites.
For the following setup of the report layout, if the desired bands do not exist in your report, add them by right clicking on an existing band and then choosing the desired type of band from the drop-down menu. Only bands that do not already exist in the Report Designer can be added to the report.
- Add a ReportHeader band to the report.
- Drag the Title field from the Master dataset in the Field List into the ReportHeaderBand1 band and adjust the size of the box to allow space for the report title.
- Drag the PROJECT and DESCRIPTION fields from the Project dataset (Master) into detailBand1. Add a Line object from the Standard Controls to improve the clarity of the output.
- Drag a label into GroupHeader1 and change the contents to "Depth of All Drillholes in this Project". This becomes the Title for each individual detail report for each Project.
- Right-click in detailBand1 and then select Insert Detail Report | "Projects_Sites".
- Drag the fields SITE_ID and Projects_Sites.END_DEPTH in to the Detail band.
- Since the field length for the fields above is very small, set the properties for the Detail band to repeat the data in three columns across the reports output page.
The final report layout is as follows:
- Click on the Print Preview tab to see the output for this report.
The first page of the report looks like the following: