Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Page No. and Page total problem
Message
 
To
04/10/2006 23:35:12
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01159582
Message ID:
01159694
Views:
18
I've done something similar in the past, but you have to run the report twice (even if the first is to no output like using a report listener, or to a fake text file that you erase when done).

The principle is this... Create a second table as distinct by the "group by" column(s) of the report with an extra column for the page count by group column (such as an integer or other numeric).

Then, in the report, call a function at the end of each page via an output field showing such Page X of Y. (and the report grouping breaks to a new page, and the page count gets reset to 1)

I've included a quick sample to do this. To see the results, and if this works for you, create a report... in the detail band, just put a textbox field to show the "RptVal" from the details table, then in the PAGE FOOTER, put a textbox with something like

"Page: " + str( _pageno ) + " of " + str( UpdGroupPg() )

Make sure your data group is set to my sample column of "RptGrp" column and each group on new page, restarting to page 1.
rand(-1)
SELECT 0
CREATE CURSOR C_GrpPageCnt ( rptGrp i, pgCnt i )
INDEX on RptGrp TAG RptGrp
INSERT INTO C_GrpPageCnt VALUES ( 1, 0 )
INSERT INTO C_GrpPageCnt VALUES ( 2, 0 )
INSERT INTO C_GrpPageCnt VALUES ( 3, 0 )


CREATE CURSOR C_TmpDetails ( rptgrp i, rptval b )
SET RELATION TO RptGrp INTO C_GrpPageCnt
FOR lnI = 1 TO 30
	INSERT INTO C_TmpDetails values ( 1, RAND() * 10000)
ENDFOR 
FOR lnI = 1 TO 15
	INSERT INTO C_TmpDetails values ( 2, RAND() * 10000)
ENDFOR 
FOR lnI = 1 TO 40
	INSERT INTO C_TmpDetails values ( 3, RAND() * 10000)
ENDFOR 

REPORT FORM PgCntByGroup TO FILE fakefile.txt noconsole

REPORT FORM PgCntByGroup preview


FUNCTION UpdGroupPg()
	*/ Using MAX() on the replace to prevent resetting to lower page count
	*/ value when the second instance of the report is actually run
	replace C_GrpPageCnt.PgCnt WITH MAX( C_GrpPageCnt.PgCnt, _pageno )
	RETURN C_GrpPageCnt.PgCnt 
ENDFUNC
 
>Hi,
>When printing a new group, I set it to start on new page number 1,
>I want to print out Page 1 of 10, I use the _pagetotal for the page total,
>but when printing the new group the value of _pagetotal not correct.
>
>For example: I want,
>Group 1: Page 1 of 10
>Group 2: Page 1 of 5
>Group 3: Page 1 of 15
>
>The value of _pagetotal always 1.
>How to solve the problem?
>
>Thanks.
>Derek Yim
Previous
Reply
Map
View

Click here to load this message in the networking platform