Subject Re: [IBO] Totalising columns & 'Record not located to update' error
Author Helen Borrie
At 01:32 AM 03-06-01 +0000, you wrote:
>What is the best way to totalise a column in a grid?
>
>JobsQry is Master to ItemsUsedQry, & "LINE_TOTAL" is a calculated
>field. IB3.6Dg
>
>My approach below causes a 'Record not located to update' error when
>the ItemsUsedQry gets posted, presumably because I've hit the Eof
>within this handler. The SQLMonitor shows it's trying to post most
>Detail fields with nulls, after the Master has posted OK.

The reason for this error is that, at this point, you have not committed the inserts to the database - therefore, there is nothing there to update.



>void __fastcall TJobsForm::ItemsUsedSrcDataChange(TIB_StatementLink
>*Sender, TIB_Statement *Statement, TIB_Column *Field)
>{
> Currency total = 0;
> if (Field &&
> (Field->FieldName == "QTY" || Field->FieldName == "UNIT_PRICE") &&
> Field->IsModified &&
> ItemsUsedQry->State == dssEdit)
> {

HERE. You are testing for dssEdit state when the new rows are still in dssInsert so nothing happens.

Also note that the OnCalculateField event won't take place until the dataset is being refreshed. I'm pretty sure you can call CalculateFields manually at other times, though.

Regards,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________