Saturday 27 May 2017

Accessing page numbers in SSRS report body

This post demonstrate how to access page numbers in SSRS report body AX 2012/AX 7/ Dynamics 365. 


1. Goto Report à Report Properties à Code in Visual studio

2. Write the below logic in code

Public Function PageNumber() as String
     Dim str as String
     str = Me.Report.Globals!PageNumber.ToString()
     Return str
End Function

Public Function TotalPages() as String
     Dim str as String
     str = Me.Report.Globals!TotalPages.ToString()
     Return str
End Function

3.  Create a text box and the below expression

=Cstr(Code.PageNumber()) & Space(2) & Labels!@SYS26401 & space(2) & Cstr(Code.TotalPages())


4. Example output 1 of 4

3 comments:

  1. Thanks but getting the below error:
    The Value expression for the textrun ‘Textbox1.Paragraphs[0].TextRuns[0]’ contains an error: [BC30451] 'Labels' is not declared. It may be inaccessible due to its protection level.
    ----------------------------
    The definition of the report '' is invalid.

    ReplyDelete
  2. Is this working ?? Let me know how to overcome the above error. The definition of the report is invalid

    ReplyDelete
  3. generally the function of page number is good,thanks.

    ReplyDelete