>I have created a TQuery, SQLSumStockAmt, like this
>Select Sum( Price * Qty) TotAmt
> From "stock.db" stock
>Where PurId = :Pur_Id
>Then in the Data Module, I assign the value to the parameter and open
>the TQuery
> SQLSumStockAmt.Params[0].AsInteger := PurchasePurId.Value;
> SQLSumStockAmt.Open;
>But when I ShowMessage(IntToStr(Round(SQLSumStockAmtTotAmt.Value)));
>The value is wrong!
Wrong in what (specific) way? Result is a value of zero? A NULL value? A
nonzero value, but apparently from the wrong records?
Do you have the TQuery.DataSource property set to anything? Should not be,
unless this is the Detail table of a Master-Detail relationship.
Try using the same SQL statement, but viewing it in a visual data-aware
control. Is the result what you would expect?
Try expanding the SQL statement to include the PurID column in the SELECT
clause. (This also requires adding a GROUP BY, but just for this test
statement.) Is the value returned in the PurID column the expected one?
SELECT SUM(Price * Qty) AS TotAmt
FROM "stock.db"
WHERE PurId = :Pur_Id
What is the result of using the value of the AsString property when
displaying the result set value with ShowMessage?
ShowMessage(SQLSumStockAmtTotAmt.AsString);
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski "Television is a medium because anything well done
Felton, CA is rare."
-- Fred Allen (1894-1956)