Printing Report with "Page # of #" Format in Footer

Last reviewed: August 31, 1995
Article ID: Q101016
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 1.02, 2.0, 2.5x, 2.6x
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

To print a report with a footer that has a "Page # of #" format, you must use a user-defined function (UDF), as explained below.

MORE INFORMATION

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

REFERENCES

"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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 31, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.