Using Crystal Reports to print statements where there might be multiple page forms. I need to know how many occurrence there are of Page 1 of 2, Page 1 of 3, Page 1 of 4, etc. Our mailing department can put from 1 to 6 pages in an envelope. They require an envelope count for every print job. It can be done manually, but I'm hoping I can accomplish this in the report and print a summary at total time. Thanks in advance!
-
1Do a running total that evaluates in the same section you are resetting the page number or maybe you could do an aggregate. Depends on the grouped section.– dotjoeNov 30, 2015 at 18:21
-
Thank you for your input. I will try your recommendation.– Wanda SvensonDec 1, 2015 at 12:58
1 Answer
Running totals should work, I guess. One for the page count, one for the envelope count, resetting the page count when you increase envelope count... But I personally would go for global variables instead. That way you can calculate the number of pages in the last envelope properly, as they are not necessarily 6.
Initialization script in report head, calculation script showing a "page x of y" output in page footer and a result script for end of report for your summary.
Initialisation:
WhilePrintingRecords;
global NumberVar pageCurrent := 0;
global NumberVar envelopeCount := 1;
Calculation / display:
WhilePrintingRecords;
global NumberVar pageCurrent;
global NumberVar envelopeCount;
if pageCurrent >= 6
(
pageCurrent := 0;
envelopeCount := envelopeCount + 1;
);
pageCurrent := pageCurrent + 1;
NumberVar pageTotal := 6;
if TotalPages - (envelopeCount * pageTotal) < 0
(
pageTotal := pageTotal + TotalPages - (envelopeCount * pageTotal);
);
"Page " + pageCurrent + " of " + pageTotal
Summary:
WhilePrintingRecords;
global NumberVar envelopeCount;
Regarding TotalPages: I'm not completely sure if the variable is called exactly that, but I know there is a crystal reports variable (like "page" for the current page number) containing the total number of pages. That's what you need to calculate the number of pages in the last envelope.