I have to sum all child records each time the user changes row or column in the grid. The child records are not saved yet. They may have changed the Qty or Price, or added or deleted a record, so I need to update the total as they navigate around in the grid. I do not save the records until the user has entered them all and clicks the Save button.
The let's them see the total before saving.
>>I have a SQL statement in a form method that I call from the AfterRowColChange() event of my input grid (see code below). The purpose it total the line item prices as the user is adding rows to the grid.
>>
>>Lparameters tiQuoteNo
>>*--------------------------------------------------------------------------
>>* Calculates the total quoted price all line items on the Quote.
>>* Stores the result into thisform.nSummaryQuoteTotal property
>>*--------------------------------------------------------------------------
>>
>> Select Sum(qty*price);
>> From Quote With (BUFFERING = .t.);
>> Where Quote.quote_no=tiQuoteNo and Quote.print=.t.;
>> Into Array laQuoteTotal
>>
>> thisform.nQuoteTotalPrice=Nvl(laQuoteTotal, 0)
>>
>> Return thisform.nQuoteTotalPrice
>>
>
>Why are you using SQL to do this? You've already got all the data at hand, just save the record pointer, SUM() and restore it.