SSRS Repeat Subreport with MultiValue parameter

When you want to print a report with a given ID for example, you would just pass that single ID into a report parameter and there you go. Simple.

How about if let's say, the user wants to be able to do multiple selection of records from the UI (e.g. select multiple records in a grid) and click Print button to generate the report for each ID in one single report? It's not that hard either.

For this example I have a Service Sheet report that takes assetID and display maintenance details for that asset. Then I went ahead and created another report, put a listbox and added that report as a subreport.


I used list instead of table because SSRS2005 has a bug when exporting the report to excel.

The next thing to do is to create the multi-value string parameter. This parameter will take comma separated values for the IDs.


We need to set the dataset for the ListBox. I used a stored procedure for this one. The stored procedure will get that parameter and break each ID into its own row.



That's it. All you need to do is then set the dataset for the listbox. In the grouping field, set the field returned by the SP (in this case maintenanceRequestId). Also check 'Page break at end' so each ID report will start on the new page.

Enjoy,
Andreas

Comments

Popular posts from this blog

SharePoint 2013 anonymous access add attachments to list item

CRM Plugin - Parent and Child Pipeline

Sitecore custom publish agent from specific node and at a specific time