Suppress the Page Header on the last pages

Friday 29 April 2016 @ 7:23 pm

I have run into several situations recently where I needed to have one Page Header for most of the pages but a different page header at the end of the report. It may be that you have an object in the report footer that might add several pages after the regular report pages. This could be a subreport, a crosstab or a large block of legal boilerplate. When this happens the Page Header for those pages may need to be different. For instance you may need to turn off the column headings for those extra pages or switch to a different heading on the page. So you need some type of flag to tell the report when to switch.

Sometimes this is as simple as suppressing the Page Header with the function OnLastRecord. This probably works 97% of the time. But there are times when this approach misfires. For instance when the last record of the report is the only record on the last page. Your Page Header will be OnLastRecord but you will still want the headings on that page over the last record’s data. So here is a more complicated but more reliable method.

    1. Insert a new subsection below your last Report Footer section
    2. Suppress this new subsection of the Report Footer.
    3. Create a formula field that says this:
      //{@Set RFPassed}
      BooleanVar RFPassed := True
    4. Place this formula in the suppressed Report Footer.
    5. Use the following suppress formula for the Page Header to be suppressed:
      BooleanVar RFPassed

When the report gets to the suppressed Report Footer it triggers the formula which changes the variable from True to False. Every Page Header before that point will have seen the variable as False and won’t suppress the section. But after that point the Page Header will see the variable as True and will suppress the section.

(For examples of my most popular formulas, please visit the FORMULAS page on my website.)

Leave a Reply

Recrystallize Pro

Crystal Reports Server