1

Is there a way to trigger the row visibility depending on the page number?

i need to show a grant total at the beginning of a table and a subtotal at the end of every page, but the subtotal only, if the report will be greater than 1 Page.

I tried with some code execution on the footer / header section and store the PageNumber, because Globals!PageNumber isn't accessible from the body. But no effect, seems the footer and header section is created later so my variable in the report code is always 0 while reading it in the table row hidden expression.

How could this be done? Any different ideas how to hide a table row on first page?

Dom84
  • 852
  • 7
  • 20

1 Answers1

2

Similar to re-setting page number in this post, you can add custom code to check what page you are on and then call setPageNumber function from the header for first page only and checkIfFirstPage function in Visibility Expression for your row:

Shared pageNumber as Integer

Public Function setPageNumber()
  pageNumber = 1
  Return newPage
End Function

Public Function checkIfFirstPage() as Boolean
  Dim isFirstPage as Boolean
  If (pageNumber = 1)
      isFirstPage = true
      pageNumber = pageNumber + 1
  Else
      isFirstPage = false
  Endif
  Return isFirstPage 
End Function

To add custom code, open Report properties window, Code tab:

enter image description here

To call setPageNumber from report header on first page only - you can add small text box in the header and set it to display white on white (so it won't show the value). Set the expression of the text box to:

= IIF(Globals!PageName = 1, Code.setPageNumber(), 0)

Another approach to your problem is to use Variables and text box in the header similar to this post.

InitK
  • 1,261
  • 13
  • 21
  • thanks. could you explain "...call setPageNumber function from the header for first page only..."? Where do i set this? You are talking from the page header? how to call it for first page only? my page header is shown on every page – Dom84 Jan 30 '18 at 08:19
  • @Dom84: I added the example of how you can call the function. – InitK Jan 30 '18 at 16:22
  • thanks for your effort. I solved it now with table header and footer. – Dom84 Jan 31 '18 at 07:45