How to: Add a Subreport and Parameters (Report Builder 2.0)

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. For more information, see Working with Data Regions (Report Builder 2.0).

To add a subreport

  1. On the Insert tab, click Subreport.

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

  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 box, type the name of the report, or click Browse. You can specify the report in the several ways. For more information, see Specifying Paths to External Items (Report Builder 2.0).

  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 or choose it from the list box. This name must match a report parameter, not a query parameter, in the subreport. If the subreport is in the project, you can choose the parameter from the drop-down list.

  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 that references a field or other object in the main report.

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

    Note

    If a parameter is missing from the Parameters list and the subreport has a default value defined, the subreport will be process correctly.

  7. To delete a subreport parameter, click the parameter in the parameter grid, and then click Delete.

  8. To change the order of a subreport parameter, click the parameter, and then click the up button or the down button.

    Changing the order of a subreport parameter does not affect the processing of the subreport.