FIX: Incorrect Group Footer Sum Using Previous in Preview

Last reviewed: September 22, 1997
Article ID: Q102463
2.5x 2.60 WINDOWS kbtool kbprint kbfixlist kbbuglist

The information in this article applies to:

  • Microsoft FoxPro for Windows, versions 2.5x, 2.6

SYMPTOMS

The sum in a report group footer displays incorrectly when you choose Page Preview from the Report menu and use the Previous button to return to a page of the report that contains only one record in the group. However, the report does display correctly when the Next button is used, and it also prints correctly.

RESOLUTION

To work around this problem, use a user-defined function (UDF) instead. Below is an example of a simple UDF that returns a group sum to the group footer of a report. The expression in the group footer is "grpsum(company)" (without the quotation marks), where COMPANY is the field that the report is being grouped on. YTDPURCH is the numeric field that is being summed.

   PARAMETER grpvar
   * Store the current record number to a variable because the SUM
   * command moves the record pointer to the end of the file.
   m.rec=RECNO()
   SUM ytdpurch FOR company=grpvar TO sumvar
   * Set the record pointer back to the correct record.
   GOTO m.rec
   RETURN sumvar

To use this code, place it in a file called GRPSUM.PRG and save it in the same directory as the report.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in FoxPro version 2.6a for Windows.

MORE INFORMATION

Steps to Reproduce Problem

  1. Create a report in FoxPro for Windows using CUSTOMER.DBF in the TUTORIAL subdirectory, and place the numeric field YTDPURCH on the detail line.

  2. From the Report menu, choose Data Grouping, group on the COMPANY field, and have each group start on a new page.

  3. Copy the YTDPURCH field on the detail line, and paste it into the group footer band. Double-click the field. In the Report Expression dialog box, select the Calculate option, then select Sum. In the Reset box, select Customer.Company.

  4. From the Report menu, choose Page Preview, and use the Next button to move through the report one page at a time. Note that each group has only one record, so the ytdpurch and its subtotal on the group footer are the same. After choosing Next at least two times, choose Previous, and note that the subtotal is now incorrect for each group that contains only one record (except the first group). The subtotal displayed is actually the subtotal for the group on the preceding page.


Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 fixlist2.60a
buglist2.50 buglist2.50a buglist2.50b buglist2.60 RWriter
KBCategory: kbtool kbprint kbfixlist kbbuglist
KBSubcategory: FxtoolRwriter
Keywords : FxtoolRwriter kbbuglist kbfixlist kbprint kbtool
Version : 2.5x 2.60
Platform : WINDOWS
Solution Type : kbfix


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: September 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.