Crystal Reports - Hide page header if there in no

2020-06-05 03:28发布

How to hide a page header if there is no record(details section) on last page. Page header must be shown on last page if there is some data on last page otherwise hide the page header.

Formaula pagenumber = totalpagecount won't work as it will always suppress the last page's header.

3条回答
放我归山
2楼-- · 2020-06-05 03:40

I've found better, and working solution to this answer (just tweaked Noa's code a bit):

WhilePrintingRecords;
Global BooleanVar finished;
finished := OnLastRecord AND NOT OnFirstRecord

and it works, even if details contains only one row.

查看更多
beautiful°
3楼-- · 2020-06-05 03:40

You may be able to adapt Crystal Reports: Display a Message When Report Has No Data to meet your needs.

查看更多
\"骚年 ilove
4楼-- · 2020-06-05 04:05

Put this formula in a suppressed field in the detail section:

WhilePrintingRecords;
Global BooleanVar finished;
finished := OnLastRecord

And make this the Suppress formula in the page header:

Global BooleanVar finished
  • Before finished is initialized the page header will show.
  • Once you print a detail record it'll be set to false.
  • When you finally reach the last detail section, finished is set to true.
  • If you happen to reach another page header, finished is still true, and Crystal will suppress the header.

It's an interesting problem. I've encountered this behavior before but never tried to solve it. I think you need to use a variable because in a page header, the usual options like Next() and OnLastRecord can't distinguish between having one more record to print and having no more records to print. I think running totals would have the same problem – the values would be the same on a page with one more record to print, and on a page with no records to print.

查看更多
登录 后发表回答