FIX: CALCULATE SUM() on Currency Field Gives Illegal OperationLast reviewed: October 29, 1997Article ID: Q161053 |
The information in this article applies to:
SYMPTOMSPerforming a comparison on a value created with the CALCULATE SUM() function causes and illegal operation error. In Windows 95, the error message states the following:
This program performed an illegal operation and will be shut down.After pressing the Details push button, the following message appears:
VFP caused and invalid pagefault in module VFP .EXE at <register address>.In Windows NT 4.0, the following error appears:
An application error had occurred and an application error log is being generated. VFP.EXE Exception: access violation.This behavior does not occur in Visual FoxPro 3.0a.
RESOLUTIONThe use of the STR() and VAL() functions may prevent this error. The modified code example below shows the implementation of this resolution:
SET TALK OFF CREATE TABLE junk (amt y) INSERT INTO junk (amt) VALUE(1.00) INSERT INTO junk (amt) VALUE(0.20) CALCULATE SUM(amt) TO mx mx=STR(mx) && Converts the value from numeric to character type. mz = (VAL(mx) < 0) && Converts mx back to numeric data type. ? mz STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual FoxPro 5.0a.
MORE INFORMATIONThe following code illustrates this behavior. The use of other aggregate functions, such as AVG(), in the CALCULATE function produces similar results.
Steps to Reproduce BehaviorEnter the following code in a program and execute:
SET TALK OFF CREATE TABLE junk (amt y) INSERT INTO junk (amt) VALUE(1.00) INSERT INTO junk (amt) VALUE(0.20) CALCULATE SUM(amt) TO mx mz = (mx < 0) ? mzThe error occurs during the comparison of the variable created with the CALCULATE SUM() function and another value. In the example above, initially declaring the variable mx numeric does not prevent the error. Keywords : buglist5.00 FxprgGeneral vfoxwin vfpfix5.0a kbprg kbbuglist kbfixlist Version : 5.0 Platform : WINDOWS Issue type : kbbug Solution Type : kbfix |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |