Access Page Number in Report Body In SSRS

I want to use Globals!PageNumber in the body part of the report. How can I access the body of the report?

I am using SQL Server Reporting Service 2008 R2 .

+4
source share
4 answers

Create functions in the code under the report properties:

Page number:

 Function PageNumber() As String Return Me.Report.Globals!PageNumber End Function 

Total Pages:

 Function TotalPages() As String Return Me.Report.Globals!TotalPages End Function 

Access to it in the body using the expression:

 =code.PageNumber & " of " & code.TotalPages 

Check out Concat function example

+8
source

Unfortunately, in Reporting Services (prior to RS2008), each page will display "Page 1 of 1." The problem is that the body is displayed in front of the header and footer, so the code cannot access the correct pagination, because it is determined AFTER all the elements in the body.

If your report is a large table with a predefined number of rows in each table, try using row_number in your SQL as a workaround to manually calculate page numbers: http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices / thread / c2047eee-41a8-4d79-ae58-dbf60f6e7554 /

+6
source

You cannot use the page number in the body. use it only in the report footer or header.

+4
source

To do this, you need to use the report variables :

Go to the Report Menu from the main menu in Visual Studio, . Click Report Properties . Add a new variable named PageCount (default value is 0)

Then, inside the footer header, create one text box and set the expression below,

 =Variables!PageCount.SetValue(Variables!PageCount.Value+1) 

It will automatically increase for each page.

NOTE. Do not hide it from the header or footer, SetValue will not work if you hide the field, so change the font of the text field to white. (Do whatever you want, but just don't hide it. Then you can use the expression below to get the pagenumber value inside the message body.

 =Variables!PageCount.Value 

I took a link to this answer .

+1
source

All Articles