ssrs
  1. ssrs-subreports

Subreports

Subreports are a type of SSRS report that are embedded within another report. They allow you to display detailed information related to a specific section of the main report, providing a more comprehensive view of the data. In this tutorial, we will discuss the syntax, example, output, explanation, use, important points, and summary of subreports in SSRS.

Syntax

The syntax for creating a subreport in SSRS is as follows:

  1. Create a subreport by selecting “Add New Item…” from the Report Solution Explorer.

  2. Choose the “Report” option and name the report.

  3. Add the required dataset and design the layout of the subreport.

  4. Navigate to the report where the subreport is to be embedded.

  5. Add a text box or rectangle to the appropriate section of the report and set its properties to:

Action: Go to report
Specify Report: Select the subreport from the drop-down menu or enter the path to the report.

Example

Let us consider a simple example that demonstrates the use of subreports. Suppose we have a main report that lists employee details by department, and we want to include a subreport that shows the recent projects that each employee has worked on.

  1. Create a new report titled “Employee Report”.

  2. Add a dataset named “EmployeeDS” that retrieves the necessary employee data.

  3. Design the layout of the report by adding a table that displays the employee data.

  4. Navigate to the “Department” row and add a text box to its corresponding cell.

  5. Set the “Action” property of the text box to “Go to report” and select “New Project Report” as the subreport.

  6. Create a new report titled “New Project Report”.

  7. Add a dataset named “ProjectDS” that retrieves the necessary project information.

  8. Design the layout of the report by adding a table that displays the project data.

  9. Save the report.

  10. Preview the main report and navigate to the “Department” row. Click on the text box to view the subreport.

Output

The output of the main report will display employee details by department, and will include a link to the subreport that shows the recent projects that each employee has worked on.

Explanation

In the example above, we created a subreport that displays the recent projects that each employee has worked on. We then embedded this subreport within our main report by adding a text box to the appropriate section and setting its “Action” property to “Go to report”. This allows the user to click on the link and view the detailed information related to a specific employee.

Use

Subreports are useful when you want to display more detailed information related to a specific section of the main report. They allow you to provide a more comprehensive view of the data, without cluttering the main report with unnecessary details.

Important Points

  • Subreports can be activated by clicking on a link within the main report.

  • The properties of the subreport (size, layout, fonts etc.) can be modified independently from the main report.

  • Subreports can be nested within other subreports to display even more detailed information.

Summary

Subreports are a powerful tool in SSRS that allow you to display more detailed information related to a specific section of the main report. They are activated by clicking on a link within the main report and can be modified independently. Subreports can be nested within other subreports to display even more detailed information.

Published on: