How to place totals or other information on the last page of the report in the page footer (130865)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft FoxPro for Windows 2.5
  • Microsoft FoxPro for Windows 2.5a
  • Microsoft FoxPro for Windows 2.5b
  • Microsoft FoxPro for Windows 2.6
  • Microsoft FoxPro for Windows 2.6a
  • Microsoft FoxPro for MS-DOS 2.5
  • Microsoft FoxPro for MS-DOS 2.5a
  • Microsoft FoxPro for MS-DOS 2.5b
  • Microsoft FoxPro for MS-DOS 2.6
  • Microsoft FoxPro for MS-DOS 2.6a
  • Microsoft FoxPro for Macintosh 2.5b
  • Microsoft FoxPro for Macintosh 2.5c
  • Microsoft FoxPro for Macintosh 2.6a
  • 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 Q130865

SUMMARY

When using the Report Writer or the Report Designer in Visual FoxPro, you can use the Summary band to place information at the end of the report on the bottom of the last page where the page footer is located.

By design, the Summary band places information at the end of a report, but the information is positioned right after the last record printed. However, you may want to place the information at the bottom of the page where the page footer is located. This article describes how to accomplish this.

MORE INFORMATION

Do not use the Summary band. Instead, place the expressions that hold the summary information on the page footer with a conditional IIF statement in the expression that checks for the last record of the table. Below are the steps needed to place the summary information in the page footer section.

Before creating or running the report, ensure that the rectotal variable used in the conditional IIF below is already set to the total number of records that need to be printed. To do this, type the following command in the Command window to get the total number of records in a table:
   rectotal=RECCOUNT()
					
If the report is going to use a FOR clause, use the same FOR condition in the COUNT command to store the number of records to be printed in the rectotal variable. For example, use this command:
   COUNT FOR fieldname="whatever" TO rectotal
					

Step-by-Step Example

Method 1 for FoxPro for Windows versions 2.x

  1. Open the report.
  2. Make a field expression by choosing the AB tool that enables you to make a report expression.
  3. In the report expression box, type:
          IIF(rectotal=counter, "Yes we are at the end!","")
    							
  4. Select Variables from the Report menu.
  5. In the variable text box, type this variable name:
          counter
    							
  6. In the Value to Store text box, type this number:
          1
    							
  7. Select the Sum option in the Calculate text box.
  8. Make sure that the Reset selection is at "End of Report."
  9. From the Report menu, select Page Review.
You will see the phrase "Yes we are at the end!" located in the page footer of the last page only. This simulates a Summary band that puts information at the bottom of the last page of a report.

NOTE: If you are using Visual FoxPro and the Print Area is set to "Whole Page" in the Page Setup dialog box, the information in the page footer may not appear. Sliding the Page Footer bar down one or more lines in the Report Designer makes the Page Footer information appear.

Method 2 for Visual FoxPro for Windows

  1. Open the report.
  2. Create a field expression by selecting the AB tool from the Report Controls toolbar that allows you to create a report expression.
  3. In the report expression box, type the following:
          "Yes, we are at the end of this Visual FoxPro report!"
    							
  4. Select the Print When command button.
  5. In the Print Only When Expression Is True text box, type:
          recno()=reccount()
    							
    NOTE: This expression does not work in FoxPro 2.x.
  6. From the Report Menu, select Page Review and you now see the phrase "Yes, we are at the end of this Visual FoxPro report!" located in the page footer of the last page only.

    NOTE: This simulates a Summary band that puts information at the bottom of the last page of a report.
To print a calculation you may substitute a calculation expression for the text expression.

Modification Type:MajorLast Reviewed:2/18/2005
Keywords:kbcode KB130865