_PAGETOTAL System Variable
Contains the total number of pages in a report.
You can use _PAGETOTAL to set up "Page X of Y" numbering in reports. _PAGETOTAL is supported in both development and run-time versions of Visual FoxPro and in all reporting operations, including REPORT FORM...TO FILE...ASCII and with optional arguments such as RANGE.
Specifies a positive number representing the total number of pages in a report.
You can set _PAGETOTAL at any time. Visual FoxPro evaluates and updates _PAGETOTAL only when a report operation such as REPORT FORM occurs. At the beginning of the report operation, Visual FoxPro initializes _PAGETOTAL to a value of 0, regardless of whether _PAGETOTAL is used on the report.
If you include _PAGETOTAL anywhere in a Visual FoxPro report, Visual FoxPro performs two passes through the report. The first pass is not visible or printed and calculates the _PAGETOTAL variable. During the first pass, _PAGETOTAL is set to a value of -1.
For performance reasons, you can suppress a two-pass report by not calling _PAGETOTAL in a print preview using an expression such as the following:
TRANS(_PAGENO) + IIF(SYS(2040)="1", "", " OF " + TRANS(_PAGETOTAL))
If you do not include a reference to _PAGETOTAL in the report, Visual FoxPro sets the value of _PAGETOTAL to the total number of pages at the end of printing and performs only one pass through the report.
You can force a second pass through the report using an expression such as the following:
IIF( _PAGETOTAL = 0, "","" )
Initiating another pass allows for additional operations using report variables such as reporting % of the total number of pages.
For a second pass to occur, in previous versions of Visual FoxPro, you needed a reference to _PAGETOTAL in the report layout. In Visual FoxPro 9.0, you can also use a ReportListener reference on your REPORT FORM command. By setting the ReportListener's TwoPassProcess property to .T. before a report run, you can force the report to perform two passes, even if you have not used _PAGETOTAL in any expressions in the report. For more information, see.
The value of _PAGETOTAL should equal the value of _PAGENO at the end of printing a report, regardless whether the report includes _PAGETOTAL.
The following example illustrates how to include "Page X of Y" numbering in your report by using the _PAGETOTAL system variable and adding the following expression in the report textbox:
"Page " + TRANS(_PAGENO) + " of " + TRANS( _PAGETOTAL)