ID: Q101016
The information in this article applies to:
To print a report with a footer that has a "Page # of #" format, you must use a user-defined function (UDF), as explained below.
NOTE: This technique does not work in FoxPro 2.x for Windows.
To obtain the total number of pages, the report must be run twice as the following code demonstrates:
CLEAR
CLOSE DATABASES
USE file.dbf
pgcnt=0
check=.T.
Old_Con=SET('CONSOLE')
SET CONSOLE OFF
REPORT FORM filename FOR condition NOCONSOLE
SET CONSOLE &Old_Con
REPORT FORM filename FOR condition
PROCEDURE pgcnt
check=.F.
pgcnt=_PAGENO
RETURN ''
The CHECK variable is used to make sure that the PGCNT() function is run
only one time. The following IIF() function is required in the Summary
band:
IIF(CHECK=.T.,PGCNT(),'')
The IIF() function checks to see if the CHECK variable is true the first
time it runs the report; if CHECK is true, it will run the PGCNT()
function. The PGCNT() function simply stores the _PAGENO variable to
another variable called PGCNT. In the final report, PGCNT will then have
the correct value.
On the report layout, the footer would contain:
Page _PAGENO of PGCNT
"Commands & Functions," version 2.0, page C3-662 "Language Reference," version 2.5, page L3-820
Additional reference words: VFoxWin FoxDos 1.02 2.00 2.50 2.50a 2.50b 2.60 2.60a 3.00 no num header page # of # page number report count current RWriter KBCategory: kbtool kbprint kbprg kbcode KBSubcategory: FxtoolRwriter
Last Reviewed: August 31, 1995