Suppress a page header if no details

Angelmar
Angelmar used Ask the Experts™
on
Can someone help me with a formula for a report  that will suppress the page header if there are no details on the page(or second page). Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Do you mean that there are no records at all, or do you, for example, have certain records that are shown on certain pages and you're trying to suppress the page header on specific pages if there are no records for those pages (but there could be records for other pages)?

 James
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Are you trying to print a blank page in the middle of the report?

Do you have the KEEP TOGETHER set so you get blank pages in a report?

mlmcc

Author

Commented:
No details but report footer is present. It prints the header even if there are no details shown, as long as the RF is there it prints.
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

You could do a running count of the details on the page, and if the count is zero, surpress the page header from printing.

Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
The problem is when the page header is printed there is no easy way to determine ifthere will be records on that page.

You could try suppressing based on the OnLastRecord test but if the report has read the last record but not printed it yet you might suppress when you don't want to.

mlmcc
If the report is actually reading no records at all (eg. the record selection is filtering everything out), then, somewhat to my surprise, I found that a formula like the following can be used to suppress the page header section (as well as the detail, report header, report footer or page footer).

IsNull (Count ({table.field}))


 I tried checking the Count when no records were read, but instead of 0, as you might expect, the field was "blank".  So I tried the IsNull test and, to my surprise, it actually worked.  :-)

 James

Author

Commented:
IsNull (Count ({table.field})) did not work for me. It still shows up.

how would I do a running count on the details.
Pick a field that shows up in your details section, and do a 'Count' running total on it, then compare against that for determining if you surpress or not.

Author

Commented:
zebulonPi - not sure how to reset the count once the page changes and have it still work.

The running total doesn't distinguish between pages. I am trying to get the header not to show up since no details show up(only report footer).
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
That indicates you are on the last record.

Did you try suppressing the page header with OnLastRecord

mlmcc

Author

Commented:
Yes, but it only works if for my specific situations where no details show up on the page(i.e. last record was at the bottom of the previous page). If the last record prints on the next page, it suppresses the page header. Which isn't what I want. I still want the header to show up if there are any details printed.
Got it!

Set up two formulas:

1st one called count, set up like this:

WhilePrintingRecords;
if not isnull(whatever field you want) then numberVar x:= x+1;

2nd one called reset, set up like this:

whileprintingrecords;
numbervar x:=0

and, finally, go into the Section Expert for the Page Header, click off Surpress, click the formula button, and put this in:

{@count} = 0

This works, I tested it!
Sorry, put the 'count' formula in the details section, and the 'reset' in the page footer!!

Author

Commented:
It looks like I have to keep OnLastRecord in the  suppress formula, correct?
I didn't, and it didn't phase me, but I also didn't set up a complex report. Try it with and without, see how you do.

Author

Commented:
numberVar is not resetting and the header is still showing up.
You put the 'reset' formula, with this code:

whileprintingrecords;
numbervar x:=0

in the page footer?

If that's the case, then it's not getting to run that code before it runs another page... which doesn't make sense.

Try putting the 'count' variable in your details line temporarily , so you can see what it's counting. You may also want to put it in your header as well, again so you can see the count.

What's the last section you see on a "page" when it runs?

Author

Commented:
count is 1 on the first page and 1 on the second page

Author

Commented:
sorry, at the headers
Do you want the first page to show, but not the second? Are there records on the first page, but not the second?

You may need to move the 'reset' formula to another section, one that Crystal will come across BEFORE that second page prints.

What's the LAST section that shows on the first page of the report? You'll see it in the tan area to the left of the actual data... it'll say something like GH1, D, GF1, something like that.

Author

Commented:
It will vary depending on the number of records that print out. It may be page 2 or 3 that needs the header suppressed. My last section on the page is Df, PF

Author

Commented:
Had no other choice but to add a group and compare group total with running count. Thanks for your help. You pointed me in the right direction
Sorry man, my job caught up with me, didn't mean to take off in the middle of the fix.

Glad you got it working!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial