Old blog. Blog moved to thomasgathings.com
I would delete this...but I don't see the option

SQL Server Reporting Services Tip: Pass dataset results to a subreport to increase reuse and separate concerns

Friday, November 13, 2009 2:05 PM
How do I pass dataset results to a subreport?  In the past, my answer warranted too heavy lifting: duplicate filtering logic and query scope in the subreport.
I came across this need as I was considering reusability in reports by leveraging subreports. This particular project, like many, has parent/child relationships.  In reporting, this manifests in some typical use cases, such as:
·         User wishes to see a list of the parent records that meet some search criteria
·         User wishes to see details for that parent, including lists of its children
Further, some of the child types need to be shown together (across different parents). For example, show me southeast sales across all product lines. With this use case in mind, I can use a single report to filter the master and use the resulting dataset to filter subreports. The concept is realized with the following steps:
·         Create a subreport that takes the master primary key as a multi-valued parameter
·         Create a master report with search criteria
·         In the master report, add a new parameter ‘ResultsOfSearch’, ensuring
o    It is Internal
o    It is Multi-value
o    Its default values come from the resulting dataset
·         Add the subreport, setting its parameter value to =Parameters!ResultsOfSearch
 
That’s it. Now, the subreport will display all child records for parents that meet search criteria. The subreport is easily reused on the parent details report by passing the single parent id to the subreport.


  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: SQL Server Reporting Services Tip: Pass dataset results to a subreport to increase reuse and separate concerns

Thank you! That was a great hint! However, there was a little struggle on the way, because I defined that subreport parameter as Internal. It was throwing an error: "The report parameter [...] is read-only and cannot be modified." untill I changed in to a Hidden parameter. All works now, thanks! 8/18/2010 2:04 PM | Tatyana

Post a comment