开发者

SSRS 2005: Group page numbers resetting, view xx from xx

On SQL Server 2005, Reporting services I have printed form (e.g. invoice), which can be multi-page. I need to print a lot of such forms (e.g. all invoices for specified customer and for specific period) by one click. I put the layout in the table and group all info by the开发者_高级运维 invoice number, so for the whole printed form it's fine, I've got, what I want. For all, except page numbering. Each invoice, if it's multi-page, should have in the footer page numbering like page xx from xx.

Is it possible to calculate the total number of pages for the group?


The blog post Reset Page Number On Group describes how to reset the page number at the end of each group. It simply requires a small custom code function and an expression for the page number.

In summary (quoted from the article):

Step 1: Make sure there's a textbox in the report which contains the group expression

Step 2: Add shared variables to track the current group and page offset

Shared offset as Integer
Shared currentgroup as Object

Step 3: Add a custom function to set the shared variables and retrieve the group page number

 Public Function GetGroupPageNumber(group as Object, pagenumber as Integer) as Object
   If Not (group = currentgroup)
     offset = pagenumber - 1
     currentgroup = group
   End If
   Return pagenumber - offset
 End Function

Step 4: Use the function in the page header or footer

=Code.GetGroupPageNumber(ReportItems!Category.Value,Globals!PageNumber)

SSRS 2008 - For those finding this link in response to the newer versions of the report server information about this same issue can be found here: MSDN Blog - Reset Page Number

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜