Dig Me Out (Resetting Report Page Numbers)

Chris hasn't gotten a chance to update his Sleazy Hacks Weblog so I thought I would post this in the meantime.

Resetting the page number in a report isn’t natively supported in Reporting Services, but there is a partial workaround.

First, add this goes in Report code block (you can do this via the Report Properties dialog in VS)

Shared offset As Integer

Public Function GetPN(reset As Boolean, pagenumber As Integer) As Integer
If reset
offset = pagenumber - 1
End If
Return pagenumber - offset
End Function

Then, add a textbox in the page footer or header with the following expression:

="Page " & Code.GetPN(Not(ReportItems!tag.Value Is Nothing),Globals!PageNumber)

The texbox named “tag” is any textbox in the group header.  Make sure the group header is NOT marked to repeat on each page, otherwise you’ll get a reset on each page.
 
Note: Since the offset must be shared (so that this will work across multiple callbacks to the server), if more than one person runs the report at the same time they’ll smash each other.  So unless this is only ever going to be run as a subscription, you’d need to modify the offset to be a hashtable based on username. If the same user runs the report more than once at the same time, they’d screw up their page numbers, but that’s probably not worth worrying about.