How to: Add a Subreport and Parameters (Reporting Services)

Add subreports to a report when you want to create a main report that is a container for multiple related reports. A subreport is a reference to another report. To relate the reports through data values (for example, to have multiple reports show data for the same customer), you must design a parameterized report (for example, a report that shows the details for a specific customer) as the subreport. When you add a subreport to the main report, you can specify parameters to pass to the subreport.

You can also add subreports to dynamic rows or columns in a table or matrix. When the main report is processed, the subreport is processed for each row. In this case, consider whether you can achieve the desired effect by using data regions or nested data regions.

To add a subreport

  1. In Design view, click Subreport in the Toolbox.

  2. On the design surface, click a location on the report and then drag a box to the desired size of the subreport. Alternatively, double-click the design surface to create a subreport of fixed size.

    Note

    If the subreport is in the project, you can drag the report from Solution Explorer onto the design surface to create a subreport.

  3. Right-click the subreport, and then click Subreport Properties.

  4. In the Subreport Properties dialog box, type a name in the Name text box or accept the default.

  5. In the Use this report as a subreport list box, type the name of the report. The name of the report can be specified in the following ways:

    • For a report in this project, select the name of the report from the drop-down list.

    • For a report published to a report server configured for native mode, use a full or relative path to the report, without the file name extension. If the report is in the same folder as the current report, use the name of the report only. If the report is in a different folder, use a relative path to the report (for example, ../Reports/DetailReport).

    • For a report published to a report server configured in SharePoint integrated mode, use the name of the report including the file name extension (for example, DetailReport.rdl). The subreport must be in the same folder as the main report. Relative paths are not supported.

  6. Click OK.

To specify parameters to pass to a subreport

  1. In Design view, right-click the subreport and then click Subreport Properties.

  2. In the Subreport Properties dialog box, click Parameters.

  3. Click Add. A new row is added to the parameter grid.

  4. In the Name text box, type the name of a parameter in the subreport. This name must match a report parameter in the subreport. If the subreport is in the project, you can choose the parameter from the drop-down list. If the subreport is on the report server, run the report in Report Manager, and on the Properties tab, click Parameters.

    Note

    The parameter name must match the name of a report parameter, not a query parameter.

  5. In the Value list box, type or select a value to pass to the subreport. This value can be static text or an expression pointing to a field or other object in the main report.

  6. Repeat steps 3-4 to specify a value for each subreport parameter.

    Note

    All parameters that are required by the subreport must be included in the Parameters list. If a required parameter is missing, the subreport is not displayed correctly in the main report.