Microsoft KB Archive/132727

= How to use a user-defined function to calculate percentages in a report group footer in Visual FoxPro =

Article ID: 132727

Article Last Modified on 2/17/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition

-



This article was previously published under Q132727



SUMMARY
To calculate percentages of a group total in report using the Report Writer, you must create a UDF (user defined function).



MORE INFORMATION
The 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 public variable for sum total msum=0 y=RECNO      && store record number to variable so total from * previous group is not added on  x=  && store field which is grouped to variable SUM FOR x= TO msum GO y  RETURN "" Put this UDF in the group header. Add a text box to the group footer to display the results of the Msum variable.

For more information about UDFs, please see the following article in the Microsoft Knowledge Base:

113754 "Syntax Error" When Verifying UDF in Report Writer

Additional query words: VFoxWin

Keywords: KB132727

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.