Thursday, January 10, 2013

Resetting SSRS Report page numbering based on a group

We had yet another situation today where a client was using a SQL Server Reporting Services (SSRS) report as an invoice, and needed the page numbering reset every time a new invoice started (one execution of the report includes invoices for multiple customers).

For instance, if the first invoice is 2 pages long, and the second invoice is 3 pages long, the page numbering on the 5 pages of the reports should be:

Page 1 of 2
Page 2 of 2
Page 1 of 3
Page 2 of 3
Page 3 of 3

This was a real pain back in the day.  In fact, before SQL Server 2008 R2, I don' think it was possible to reset the "of x" portion of the page numbering.  I was only ever able to reset the current page number to 1 when a new group started.

But, with the introduction of SQL Server Reporting Services 2008 R2, it is possible to do this without a lot of .NET coding behind the report.

Here's a link to the best blog post I've found on this topic.  For our purposes, all we needed to do was set the PageName property for the invoice header group to be the InvoiceNumber from the dataset.  Then set the page properties as listed in this blog.

http://blogs.msdn.com/b/robertbruckner/archive/2010/04/25/report-design-reset-page-number-on-group.aspx

Enjoy!

No comments:

Post a Comment