Suppress report page header when page has no detail lines
Suppress report page header when page has no detail lines
I'm using ReportDeveloper 6.0. Have a multi-page report, and am trying to figure out a way to suppress the page header if the page only has footers. For example, the first 3 pages have detail and subtotal rows. However, the LAST page only has the totals and footer notes, so it should not print the page header. Any suggestions?
Re: Suppress report page header when page has no detail lines
Yes, it should be possible and I'll provide a suggestion or direction to try coding, but first a little background: ReportBuilder (RB) prints the report pages in this way (unless later TD versions changed this, which I doubt):
FIRST PAGE
If Report Header contains a printable item, like an input item, static text, etc. then RB prints the Report Header
Else it prints the Page Header
It also prints the Page Footer if that contains something.
LAST PAGE
If Report Footer contains something, the Report Footer get printed
Else it prints the Page Footer
>>> Normally it the prints the Page Header every time. <<< This is what you want to prevent.
Open RB and any report and right-click on the Page Header section heading. Now Click Properties... See the "Conditional Display" section in the middle of the dlg. box? The prompt says "Display this block if the result of the formula is not zero "
There's where you would code something to have a formula etc. evaluate to zero/FALSE for the last page. And if you click the Formula button you'll see that there are a couple built-in RB formulas called PageNumber() & TotalPages() and NumberIFF(). See TD Help for NumberIFF and how it works.
Prototype: NumberIFF( nInput, number1, number2, number3 )
And Help states that "[NumberIFF] returns one of number1, number2, or number3, depending on the value returned by the nInput parameter."
I suggest you write a test report or a simple way to test what code might work, and though I have not tried this it's possible that a formula that would return a 0/FALSE when PageNumber = TotalPages is what you want. Maybe a formula like this:
NumberIFF( TotalPages() - PageNumber(), 0, 0, 1 )
That is, return 1/TRUE is page # != total pages yet, return 0/FALSE when page # = total pages. There might be an 'off by 1' issue here because RB might not increment the Page # value internally until after it has printed that page. If so, then something like ( TotalPages() - (PageNumber()+1), 0, 0, 1 ) might be needed, for example. And note parens. in bold.
FIRST PAGE
If Report Header contains a printable item, like an input item, static text, etc. then RB prints the Report Header
Else it prints the Page Header
It also prints the Page Footer if that contains something.
LAST PAGE
If Report Footer contains something, the Report Footer get printed
Else it prints the Page Footer
>>> Normally it the prints the Page Header every time. <<< This is what you want to prevent.
Open RB and any report and right-click on the Page Header section heading. Now Click Properties... See the "Conditional Display" section in the middle of the dlg. box? The prompt says "Display this block if the result of the formula is not zero "
There's where you would code something to have a formula etc. evaluate to zero/FALSE for the last page. And if you click the Formula button you'll see that there are a couple built-in RB formulas called PageNumber() & TotalPages() and NumberIFF(). See TD Help for NumberIFF and how it works.
Prototype: NumberIFF( nInput, number1, number2, number3 )
And Help states that "[NumberIFF] returns one of number1, number2, or number3, depending on the value returned by the nInput parameter."
I suggest you write a test report or a simple way to test what code might work, and though I have not tried this it's possible that a formula that would return a 0/FALSE when PageNumber = TotalPages is what you want. Maybe a formula like this:
NumberIFF( TotalPages() - PageNumber(), 0, 0, 1 )
That is, return 1/TRUE is page # != total pages yet, return 0/FALSE when page # = total pages. There might be an 'off by 1' issue here because RB might not increment the Page # value internally until after it has printed that page. If so, then something like ( TotalPages() - (PageNumber()+1), 0, 0, 1 ) might be needed, for example. And note parens. in bold.
Jeff Luther @ PC Design
Palm Springs, California
Palm Springs, California
Re: Suppress report page header when page has no detail lines
Jeff, That's close to what I need - except that depending on the total number of detail lines, the last page MIGHT have some detail lines (in which case the page header should print) or might only have footer information (in which case the page header should not print). Is there a formula that I'm not spotting that evaluates how many detail rows will print on the page? If so, I could use that for conditional formatting.
Re: Suppress report page header when page has no detail lines
P.S. I realized after posting my previousreply and waiting to it to be OK'd here, I recalled that to implement something like I wrote you'll have to have a two-pass report for RB. Pass #1 does all the calcs. for any/all totals and there's an implied one in my prev. msg: Total Pages() has to know how many that is and it's isn't the actual total. RB then reruns the report in Pass #1 as the actual report.
(Be sure any vars. etc. you init. in SAM_ReportStart do not need to be init'd > 1 time for the life of the report. If not, then you'll need to move those assignments to SAM_ReportFetchInit. This is sent each time RB runs a single report: first when report starts, then 2nd time if two-pass is defined, in Preview mode the user scrolls ahead in the report, then click back on Page 1.)
I see that in TD Help there's a tutorial about 2-pass reports. Search for "Two Pass Total Report tutorial" in Help's Index tab.
Another idea that might work, as long as I'm here: Have a Boolean in your TD app + a corresponding Input Item in RB and init. the Bool = TRUE in your appl. Use this Input Item in your Report in the "Conditional Display" Page Header Props dlg. box. Drop down the list: It lists all input items and vars and named Formulas. Set this Bool. Now (in theory; again Ive not tried this) the Page Header only prints when it's TRUE.. I'd code something like:
(Possible that the Return from SAM_ReportFetchNext is sent after that next Page Header is printed. Then my idea won't work.)
Let us know if either of these methods worked or not, or describe your solution if you found something else.
Suggestion: you maybe code a test case if you are still having an issue. If you can write the test in an earlier version of TD v5.2, v4.2, etc. then we on this side of the hidden forum areas can run your test, assuming they have an earlier TD.
(Be sure any vars. etc. you init. in SAM_ReportStart do not need to be init'd > 1 time for the life of the report. If not, then you'll need to move those assignments to SAM_ReportFetchInit. This is sent each time RB runs a single report: first when report starts, then 2nd time if two-pass is defined, in Preview mode the user scrolls ahead in the report, then click back on Page 1.)
I see that in TD Help there's a tutorial about 2-pass reports. Search for "Two Pass Total Report tutorial" in Help's Index tab.
Another idea that might work, as long as I'm here: Have a Boolean in your TD app + a corresponding Input Item in RB and init. the Bool = TRUE in your appl. Use this Input Item in your Report in the "Conditional Display" Page Header Props dlg. box. Drop down the list: It lists all input items and vars and named Formulas. Set this Bool. Now (in theory; again Ive not tried this) the Page Header only prints when it's TRUE.. I'd code something like:
Code: Select all
> Set bPrintPageHeader = TRUE in SAM_ReportFetchStart or Init
> In SAM_ReportFetchNext
When your fetch ends and you are about to Return FALSE this msg.
Set bPrintPageHeader = FALSE
Let us know if either of these methods worked or not, or describe your solution if you found something else.
Suggestion: you maybe code a test case if you are still having an issue. If you can write the test in an earlier version of TD v5.2, v4.2, etc. then we on this side of the hidden forum areas can run your test, assuming they have an earlier TD.
Jeff Luther @ PC Design
Palm Springs, California
Palm Springs, California
Who is online
Users browsing this forum: [Ccbot] and 1 guest