jason barry
jason barry

Reputation: 19

SSRS page numbers in page footer

I wish to not include the page number (in the page footer) for the first 10 pages of the report (i.e. page 1-10). Page 1 should read i, page 2 should read ii and page 3 should read iii and so on (in roman numerals).... When it gets to page 11, this should reset the page numbers

Does anyone know of the expression I can use to achieve this. So if GlobalPage number = 1,2,3,4,5,6,7,8,9,10 do not display, or compensate the globals page number for something else.....Is this possible.

Upvotes: 0

Views: 1422

Answers (2)

Chris Latta
Chris Latta

Reputation: 20560

We'll do ths with some custom code to keep flexibility. Microsoft have some code to do the Roman numeral conversion so we'll adapt this.

Let's add the custom code we need: one function to convert an integer to a Roman numeral and one function to work out what sort of numeral to provide.

Function PageNumber(page As Integer, startArabic As Integer) As String
  If page <= startArabic Then
    PageNumber = IntegerToRoman(page)
  Else
    PageNumber = (page - startArabic).ToString()
  End If
End Function

Function IntegerToRoman (ByVal N As Integer) As String
  Const Digits = "ivxlcdm" 
  Dim I As Integer
  Dim Digit As Integer
  Dim Temp As String 

  I = 1 
  Temp = "" 

  Do While N > 0 
    Digit = N Mod 10 
    N = N \ 10 
    Select Case Digit 
      Case 1 
        Temp = Mid(Digits, I, 1) & Temp 
      Case 2 
        Temp = Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 3 
        Temp = Mid(Digits, I, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 4 
        Temp = Mid(Digits, I, 2) & Temp 
      Case 5 
        Temp = Mid(Digits, I + 1, 1) & Temp 
      Case 6 
        Temp = Mid(Digits, I + 1, 1) & Mid(Digits, I, 1) & Temp 
      Case 7 
        Temp = Mid(Digits, I + 1, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 8 
        Temp = Mid(Digits, I + 1, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Mid(Digits, I, 1) & Temp 
      Case 9 
        Temp = Mid(Digits, I, 1) & Mid(Digits, I + 2, 1) & Temp 
    End Select 

    I = I + 2 
  Loop 

  IntegerToRoman = Temp 

End Function 

To make the report more flexible, we'll add a parameter for when to revert to Arabic numerals (in case we need more than ten Roman numerals at some stage when the report gets longer). Let's call that @StartArabic and it will be an integer with the default value of 10. So now our page number expression is simply:

="Page " & Code.PageNumber(Globals!PageNumber, Parameters!StartArabic.Value)

Upvotes: 0

glh
glh

Reputation: 4972

You'll have to manually change the value i.e. putting something similar to the following in the footer:

IIf(Globals!PageNumber=1, "i", ...

Alternativally you could use a user function try VBA for number to roman numeral

Upvotes: 2

Related Questions