FIX: CALCULATE SUM() on Currency Field Gives Illegal Operation (161053)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 5.0
This article was previously published under Q161053 SYMPTOMS
Performing 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.
RESOLUTION
The 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
STATUS
Microsoft 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.
Modification Type: | Major | Last Reviewed: | 10/16/2002 |
---|
Keywords: | kbBug kbProgramming kbvfp500aFIX KB161053 |
---|
|