Print Page | Close Window

Multiple Page Counts in Report

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20238
Printed Date: 04 May 2024 at 9:44pm


Topic: Multiple Page Counts in Report
Posted By: mjsmith
Subject: Multiple Page Counts in Report
Date Posted: 20 Nov 2013 at 7:29am
I have a report structured in the following manner:

Report Header
Page Header
Group Header (Total Page Count for each group)
Details
Group Footer
Page Footer (Page N of M for each detail)
Report Footer

I'm trying to get two independent page counts working. The first is a "Total Page Count" for each group and appears in the group header. The second is a "Page N of M" for the details section and appears in the page footer. The problem is that the two counts can't be reset independently, so only one will work at a given time. Does anyone know how to solve this issue? Thanks in advance.



Replies:
Posted By: lockwelle
Date Posted: 20 Nov 2013 at 8:10am
The only thought that comes mind is using a variable...but that cannot go in the group header as the data has not been read/pages generated.

Probably the best approximation that you can get is to count the number of lines for each group and if you know how many detail lines fit on a page, you can approximate the number of pages.

It's a thought. Perhaps someone else has a better idea.

Just as an odd question...is the report footer a total of the pages in the report? Seems odd that you would have something like, on page 4 of 25, there are 10 pages for this group, and you would show page 5 of 25 with or without the group header. Just seems odd and confusing to me. Unless that you mean the Report footer would display page 1 of 10, and then in the next group page 1 of 4 (for example)...If so, you would think that you could access the count of pages for the group..

And I've been wrong before


Posted By: mjsmith
Date Posted: 20 Nov 2013 at 9:25am
Thanks for the response! I made a mistake in my original post. The Page N of M should have been in the Page Footer. I've corrected it now.

Could you please go into more detail about how to use a variable to solve the problem?

Each group in the report is a fax recipient and each detail record is a collection of several subreports that collectively form one or more documents to be faxed. Here's an example of a report with five records and two recipients broken down by page along with the desired page number print-out in parenthesis:

Fax Cover Sheet to Recipient X (7 Total Pages) Group Header 1
First Fax (Page 1 of 2) Detail 1
First Fax (Page 2 of 2) Detail 1
Second Fax (Page 1 of 3) Detail 2
Second Fax (Page 2 of 3) Detail 2
Second Fax (Page 3 of 3) Detail 2
Third Fax (Page 1 of 1) Detail 3
Fax Cover Sheet to Recipient Y (4 Total Pages) Group Header 2
Fourth Fax (Page 1 of 1) Detail 4
Fifth Fax (Page 1 of 2) Detail 5
Fifth Fax (Page 2 of 2) Detail 5

Of course the ideal solution would allow for any number of details records grouped into any number of recipients. As I mentioned before, the two page counts need to operate independently of each other, but resetting the page count will reset both. Thanks again for your response.


Posted By: Sastry
Date Posted: 21 Nov 2013 at 12:37am
Hi
 
Getting total page count on group header :
 
Create a formula like :
@count
if isnull({Groupfield}) then 0 else 1 
 
Place the above formula in detail section and insert summary and place the summary on your group header. ( If u want u can suppress this formula )
summary formula :
@pcount
sum( mailto:%7b@count%7d,Groupfield%29+1 - {@count},Groupfield)+1 (to include Fax Cover sheet) 
( I think each detail is prining in a separate page )
 
Now create a manual running total to print page numbers like 1 of 10 etc..
 
@Init
Whileprintingrecords; 
Numbervar x:=0;
 
Place the above in your group header and suppress it.
 
@Accu
Whileprintingrecords;
Numbervar x:=x+1;
"Page "&x&" of  "&{@Pcount}
 
Place this formula in page footer to print page N of M
 
Hope this helps
 
 


-------------
Thanks,
Sastry


Posted By: mjsmith
Date Posted: 21 Nov 2013 at 6:55am
Sastry,

Thanks a lot for your detailed reply!

Unfortunately, the solution you provided only works if there is one detail per page. In most cases, there will be three to four pages per record, so what I really need to count is pages and not records.

Please let me know if you have any other solutions. Thanks again!


Posted By: lockwelle
Date Posted: 21 Nov 2013 at 8:24am
what version are you on?

in XI, in the Section Expert, you can reset the page numbering...which I would guess would allow you to know the number of pages in that section, and you can change numbering in both a group header and the detail section, so you might be able to accomplish what you are after.

No, I have never done this myself (at least not in a very long time) and never with multiple sections being renumbered.

It's worth a try.


Posted By: mjsmith
Date Posted: 21 Nov 2013 at 10:09am
Thanks for the reply! I'm using Crystal Reports 2008 Version 12.0.0.549.

In section expert, I am able to reset the page number for the group, which gives me the correct Total Page Count for the cover sheet, or for the details, which gives me the correct Page N of M page counts for the individual sections, but only one will work at a time.

I'm not sure what you mean by changing the numbering in the group header and details section. Could you please elaborate?

Thank you!


Posted By: lockwelle
Date Posted: 21 Nov 2013 at 11:01am
what I was thinking was that in the group header you would reset the page number, and grab the total pages for the group, then in the detail you would change it again, and it would be the values as described in the sample above...

so all the values would be correct.

Again, I haven't done this, but I would think that from inside the group header you could write a formula or access the special value of total pages and display it in the group header. It will change in a instance as you enter the detail section, but then you have the value that you after.

That was my idea...I could be wrong and it won't work, hence, worth a try.

Changing the numbering is Resetting the page number.

HTH


Posted By: mjsmith
Date Posted: 21 Nov 2013 at 11:26am
Thanks for the reply, I understand now. Resetting the page number anywhere in the Section Expert (Report/Page/Group/Detail) resets it globally, so setting the page number to be reset in the Details and the Group resets it twice for both.

I'm not sure if there is a bug in CR or there's something that I'm missing, but Sastry's response seems like it should work if the @pcount formula is placed in the page footer instead of the details view, but despite being printed on every page, it is only incremented once per record.

Thanks again.


Posted By: lockwelle
Date Posted: 21 Nov 2013 at 11:28am
ok...well, it was worth a try.

Go with Sastry's solution then


Posted By: mjsmith
Date Posted: 21 Nov 2013 at 11:31am
His doesn't work. I get a count of records instead of a count of pages.

Thanks.


Posted By: lockwelle
Date Posted: 21 Nov 2013 at 11:37am
oh...Sorry.

If it wasn't a cover page, you could manually count the pages, but since it is a group header, you would need to have CR tell you the number of pages that it WILL print, since it hasn't printed any yet.

Perhaps Sastry has a refinement to his solution...

Sorry I couldn't help more.



Print Page | Close Window