How to set a "page # of #" counter in a report in Visual FoxPro (276501)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition

This article was previously published under Q276501

SUMMARY

PageOf.exe contains a sample Visual FoxPro report that sets a "page # of #" counter. To generate the counter, the report dynamically calculates how many lines are used on the detail line to accommodate the fields. The records on the table are divided by the amount of detail lines and then used to generate the counter.

Note This method works in Visual FoxPro 9.0 Professional Edition. However, you can also use Visual Fox Pro 9.0 Report Listener to do the same task.

MORE INFORMATION

The following file is available for download from the Microsoft Download Center:
Release Date: Nov. 1, 2000

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The PageOf.exe file contains the following files:

File nameSize
PageOf.frx7KB
PageOf.frt4KB
Employee.dbf5KB


To use the sample, perform the following steps:
  1. Download and save files.
  2. Start Visual FoxPro.
  3. From the Command window type:
    REPORT FORM PAGEOF PREVIEW
  4. Note the "Page 1 of 11" page footer. To see how the sample works, drag the detail down to expand the detail area; this causes fewer records per page and thereby increases the number of pages. You can also expand the header and footer sections of the report, and it automatically performs the calculations.
The core of the calculations are contained in two report variables called nLineCount and nLineCalc. The report also uses the Init event of the cursor in the Data Environment to save how many records are in the table. You need to adjust the code according to whether or not your table is going to hold deleted records. Here are two code samples that illustrate these two scenarios:
*!* Init Event Code to exclude deleted records.
Public nRecNo
SET DELETED ON
COUNT ALL FOR !DELETED() TO nRecNo
				
-or-
*!* Init Event Code for all records.
nRecNo = RECCOUNT()
				
This sample has limited functionality, and does not function correctly with data grouping or memo fields that stretch with overflow. Data grouping and memo fields that stretch with overflow cause an inconsistent detail line length, thereby affecting the calculations.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbdownload kbfile kbhowto kbReportWriter KB276501 kbAudDeveloper