How to Use a UDF to Calculate Percentages in a ReportLast reviewed: July 31, 1995Article ID: Q132727 |
The information in this article applies to:
SUMMARYTo calculate percentages of a group total in report using the Report Writer, you must create a UDF (user defined function).
MORE INFORMATIONThe FoxPro Report Writer calculates totals in a top down manner. To get a detail item's percentage of a total that resides in the group footer band, the total must first be calculated in the group header. This can be accomplished by using the following code in a UDF:
SET TALK OFF PUBLIC msum && initialize variable for sum total msum=0 y=RECNO() && store record number to variable so total from * previous group is not added on x=<field name> && store field which is grouped to variable SUM <numeric field name> FOR x=<field name> TO msum GO y RETURN msum && this will simply display the total in the group * header that appears in the group footerFor more information about UDFs, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q113754 TITLE : "Syntax Error" When Verifying UDF() in Report Writer |
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |