The Subreport control is a placeholder for data from a separate report. Subreports make sense when you need to nest groups of data from different data sources within a single data region, or when you can reuse a subreport in a number of reports.
Some properties of the Subreport control are described below. Note that you need to enable Advanced Properties Mode to view all properties.
Report Name: The parent report name.
Data Set Name: Select a dataset to associate with the banded list. The drop-down list is populated with all of the datasets in the report's dataset collection.
Data Set Parameters: Add data set parameters to filter the data to display in reports at preview.
Merge Transactions: Indicates if transactions in the parent report and subreport are merged.
Width: Enter a value in points to set the width of the border.
Style: Select a style for the border.
Color: Select a color to use for the border from Color Picker, Standard Colors, or Web Colors.
Keep Together: Indicates if the data inside the subreport is kept together on a single page if possible.
Message: The message to display in the data region when no rows of data are available.
Color: Select a color to use for the message from Color Picker, Standard Colors, or Web Colors.
Font Style: Apply a font style on the message. Note that if you chose a theme for Layout > Style, the text appears according to the selected theme. You can select the following styles:
Normal - Makes text appear in normal style.
Italic - Makes text appear italicized.
Text Decoration: Lets you decorate the text by use of lines. You can choose from:
Underline - Draws a line below the text.
Overline - Draws a line above the text.
LineThrough - Draws a line through the middle of the text.
Format: Select one of the common numeric formats, provided in the list.
Inherit Style Sheet: Indicates if the stylesheet from the parent report is used in the subreport.
Substitute Theme On Subreport: Indicates if the theme from the parent report is used in the subreport.
We want to create a master report that uses the Subreport control for displaying the data from another report, the details report. The master report will display Employees with the basic information - Name, Title, City, and Country, along with the list of orders, fetched from the details report.
The master report uses the List data region that will contain TextBox controls to display the data. The List data region repeats any report control it contains for every record in the dataset. The master report uses a parameter that is passed from the master report to the detail report to filter the details.
The final report will be as shown.
Create an RDL report and drag-drop the Table control onto the design area.
From the dataset, drag the following data fields to the Details row of the Table control:
[Freight]. The Header row above the details row is automatically filled with labels.
In the footer row of the table, in the extreme right cell, enter the following expression
=Sum(Fields!Freight.Value). Your table should now look as shown.
To add a report parameter, go to the Data tab and click Add next to the 'Parameters'. A parameter, Parameter1, is added.
Click Parameter1 to edit the parameter properties.
Set the Data Type property to Integer.
Enable the Hidden property for the parameter to True.
Select the Table control and go to the Properties pane.
In the Filters property, go to Show Items, and select Add Item.
Click the icon to display the filter properties.
Click the radio button next to the Filter Expression and select 'EmployeeId'.
From the drop-down next to Operator, select 'Equal'.
Click the radio button next to Value and enter the expression
Drag-drop the List data region onto the design area of the report.
Drag-drop three TextBox controls onto the List data region.
Drag-drop the Subreport control onto the List region.
From the Properties pane of the Subreport control, set the Report Name property to the detail report's name.
To use the Details report parameter, from the Properties pane of the Subreport control, go to the Report Parameters property.
Click Show Items and then select Add Item.
Click the Filter Property Icon to view the parameter properties and set the Name property to 'Parameter1'.
In the Value field, enter the following expression
Select TextBox1 and enter the expression
="Name: " & Fields!LastName.Value & ", " & Fields!FirstName.Value.
Select TextBox2 and enter the expression
= "Title: " & Fields!Title.Value.
Select TextBox3 and enter the expression
=Fields!City.Value & ", " & Fields!Country.Value.
To add the report title, drag-drop a TextBox control above the List data region.
Click inside the text box and enter the text 'Employee Orders Report (Master-Detail Report)'.
Improve the appearance of the report by resizing the controls and applying font style and alignment properties.
Preview the report.