2 report headers

RoelofRoelof Posts: 359Member
I want to use 2 report headers in a report, so for page 1 to use Header1 and the next page(s) Header2. I'm struggling to achieve that. I tried a few approaches but neither one of them worked. I'm not using the Report Page Header but defining both headers in the tablix. The reason for this approach is (compare i.e. report 10075 - Sales Order) to eliminate header space for reports with multiple pages. Base report 10075 has this huge header and shows up on each page. I want to avoid that by defining 2 different headers.
Any ideas?
Roelof de Jong
http://www.esopro.com

Answers

  • archer89archer89 ViennaPosts: 333Member
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/
  • RoelofRoelof Posts: 359Member
    I'm not sure if setting the report.pageno to a new page would help my issue.
    Roelof de Jong
    http://www.esopro.com
  • AluanAluan Posts: 46Member
    edited 2019-10-24
    Hello Roelof,
    i would probably work with the Header properties.

    For the headers after the first page i would use the report Header and clear the checkbox "print on first page".
    -> https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms156410(v=sql.105)?redirectedfrom=MSDN

    For the header on the first page you can use the tablix.

    Edit: Link didn't work - modified.
  • RoelofRoelof Posts: 359Member
    Aluan, there are still some issues with this approach:
    1. How would you solve the display of the page-number on each page, since the 'Globals!PageNumber' report variable cannot be used in a tablix.
    2. What would be the trigger to disable Header1 after page 1?
    Roelof de Jong
    http://www.esopro.com
  • AluanAluan Posts: 46Member
    Hello Roelof,
    just to make sure, are we talking about Reports with RDLC?
  • RoelofRoelof Posts: 359Member
    Correct.
    Roelof de Jong
    http://www.esopro.com
  • AluanAluan Posts: 46Member
    Alright,
    in that case i would put everything into the header and work with the hidden properties.
    To show the values for the first page set the hidden expression to:
    =Globals!PageNumber > 1

    For the values after the first page:
    =Globals!PageNumber = 1
  • RoelofRoelof Posts: 359Member
    And thats the problem. The Globals!PageNumber variable can NOT be used in a tablix (as I stated earlier). This is a real pain.
    Roelof de Jong
    http://www.esopro.com
  • AluanAluan Posts: 46Member
    edited 2019-10-28
    Correct,
    that's why you have to put everything into the header and work with textfields and maybe rectangles.
    If you work with the hidden attribute you don't have an empty space in your header.

    If that doesn't work for you, can you give me an example what information you need to display on the first and what on ther other headers?

  • RoelofRoelof Posts: 359Member
    Let me try to explain:

    Since Globals!PageNumber cannot be used in a tablix I tried with creating 2 functions: SetCounter and GetCounter:

    Public shared Counter as Integer
    Public Function SetCounter() as Integer
    Counter = Counter + 1
    Return Counter
    End Function

    Public Function GetCounter() as Integer
    Return Counter
    End Function

    In the tablix I have defined for both headers (header 1 and 2) the following in the RowVisibility property setting 'Show or hide based on an expression'. For Header1 the expression is: =Code.GetCounter <> 0. For Header2 the expression is: =Code.GetCounter = 0.
    The counter is set in the report.page in a field with expression: =Code.setCounter.
    So, the assumption is to increase the Counter when the first page-footer is triggered. And that works fine. BUT.... since the 'Code.GetCounter' in both header hiding expressions don't give the actual value I had to define both header expressions as for Header1: =ReportItems!PageCounter.Value <> 0 and Header2: =ReportItems!PageCounter.Value = 0. This is referring to the field on the Page.Footer (fieldname=PageCounter, with expression: =Code.GetCounter)
    When I compile the report I'm getting the error (as I stated earlier):
    'The Hidden expression for the grouping 'xxxx' refers to the report item 'PageCounter'. Report item expressions can ONLY refer to other report items within the same grouping scope or a containing grouping scope.


    Roelof de Jong
    http://www.esopro.com
  • AluanAluan Posts: 46Member
    Hello Roelof,

    thank you for the explanation.

    I think that won't work. As far as i know, you can't modify the table header "dynamically".
    You can set the table header for multiple pages, but you can't say "print Header1 only for Page1" and "Header2 only for the pages after Page1".

    If you want to achive what you want, you have to use the Report Header. Here you can work with the hidden properties and the Globals!PageNumber.
  • RoelofRoelof Posts: 359Member
    If possible, what would be the scenario to only use the Report Header for it?
    Roelof de Jong
    http://www.esopro.com
  • AluanAluan Posts: 46Member
    Hello Roelof,
    here you can find an example.
    -> https://pastebin.com/EPwsZWf4

    You can download it and import it as ".txt" file. It's a Report with the Number 50000.
    If you need to change the Number of the Report, open the textfile and change the 50000 in the first line.
  • RoelofRoelof Posts: 359Member
    edited 2019-11-07
    Hi Aluan,
    That worked but the problem is the white space on the report header. If I have 2 header definitions defined on the Report Header and header 2 is using less space than header 1, then the total space reserved for header 1 is still showing on pages 2 and over. That is my dilemma. I want to manage space by defining 2 different headers.
    Roelof de Jong
    http://www.esopro.com
  • AluanAluan Posts: 46Member
    Hello Roelof,
    does that work for you?
    -> https://pastebin.com/MVJ2YbSN
  • RoelofRoelof Posts: 359Member
    Hi Aluan,
    Sorry, no that doesn't work either since the report header is still involved and whatever white space I have there will be printed on the next pages. Think of this: if I have 10 lines of header on the report header, in your scenario it will still show that as white space on the next pages. I would like to see a solution that my next pages would only see 1 line instead of the 10 lines.
    Roelof de Jong
    http://www.esopro.com
Sign In or Register to comment.