General information
Category:
Coding, syntax & commands
Title:
How to calculate Grid Sum?
I have a grid class (modify from TASTRADE) that calculates Sum of a column but it gives me GPF. If I take out the 'CALCULATE' statement, everything works fine. Is this a Microsoft bug or not?
My CalExpr is: SUM(carddet_vw.qty*carddet_vw.price)
LOCAL i,lnOldArea, ;
lnOldRecNo, ;
luKey, ;
lcOrder,;
lnResult,;
lcExpression
lnResult = 0.00
IF EMPTY(THIS.CalExpr)
return lnResult
ELSE
IF EMPTY(this.RecordSource)
RETURN lnResult
ENDIF
lcExpression= " " + THIS.CalExpr + " "
lnOldArea = SELECT()
SELECT (this.RecordSource)
lnOldRecNo = IIF(EOF(), 0, RECNO())
lcOrder = ORDER()
luKey = IIF(!EMPTY(lcOrder), EVAL(lcOrder), "")
IF !EMPTY(lcOrder) AND SEEK(luKey)
calculate &lcExpression;
WHILE luKey = EVAL(lcOrder) ;
TO lnResult
ELSE
CALCULATE &lcExpression;
TO lnResult
ENDIF
IF lnOldRecNo <> 0
GO lnOldRecNo
ENDIF
SELECT (lnOldArea)
ENDIF
return lnResult
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only