SSRS report - get a page number in the report body

mark goldin 691 Reputation points
2021-07-23T18:14:03.487+00:00

I need to have a page number in the report body, but not in a table group. Is that possible? I am using latest builder.

Thanks

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,923 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Joyzhao-MSFT 15,586 Reputation points
    2021-07-26T02:12:40.09+00:00

    Hi @mark goldin ,
    You can NOT use Global!PageNumber in report body, it is only allowed in header / footer. If you just use the expression in the Report Body: ="Page "&Globals!PageNumber &" of "&Globals!TotalPages, it will have the following error.
    117753-01.jpg
    A practical method is to create functions in the code under the report properties.

    1. In Design view, right-click the design surface outside the border of the report and click Report Properties.
    2. Click Code.
    3. Enter the following Functions:

    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  
    

    As shown below:
    117676-02.jpg

    4.Access it in the body via an expression:

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

    117754-03.jpg
    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.