Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to generate unique page numbering in a report

Formula Help

How to generate unique page numbering in a report

by  MsPepperMintUSA  Posted    (Edited  )
------------------------------------------------------
Please note: The FAQ was created based on suggestion supplied by:

Ken Hamady
http://www.kenhamady.com/
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
------------------------------------------------------

PROBLEM
Using the built PageNumber function will consecutively number the pages.
You want to implement Page Numbering distinct for each record in sample report(where record ID is primary key).

SAMPLE REPORT
Record ID 1 (spans 2 pages)
Result from Page Number Function: Page 1, 2
Desired Result: Page 1, 2
Detail Name
Datil Address

Record ID 2 (spans 7 pages)
Result from Page Number Function: Page 3, 4, 5, 6, 7, 8, 9
Desired Result: Page 1, 2, 3, 4, 5, 6, 7
Detail Name
Detail Address

Record ID 3 (spans 3 pages)
Result from Page Number Function: Page 10, 11, 12
Desired Result: Page 1, 2, 3
Detail Name
Deatil Address

SOLUTION
Step 1: Group by Record ID

Step 2: Set Group Header to "repeat GH on each new page" (Access the option by right clicking on the group and select "Change Group".)

Step 3: Create two equations.
1. Equation 1 should be place in GH header and should be suppressed.

2. Equation 2 should be place in the Page Header. It will also work in the Group Header.

Here's the code:

Equation 1
Shared NumberVar factorPageCount;
If InRepeatedGroupHeader
then
factorPageCount:=factorPageCount
Else
factorPageCount:= PageNumber - 1

Equation 2
Shared NumberVar RecPageCount;
If InRepeatedGroupHeader
then
RecPageCount:= PageNumber - {@PageFactor}
Else
RecPageCount:= 1







Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top