Board index » delphi » How to re-calculate a calculated field

How to re-calculate a calculated field

Quote
Andrew Cutforth wrote:

> Does anyone know how to re-calculate a dataset's calculated fields
> without doing a Refresh.
> I have a DBGrid that needs to display some additional information
> alongside the real data fields.  I have used a TStringList to hold
> the extra info and in the OnCalcFields event I look in the
> StringList and set the calculated field.
> The only way to get it to re-calculate the field is to scroll up and
> down the grid or do a Refresh on the dataset.  Refresh is no good
> because I might be using a query which could take time.

I don't know why you don't do a refresh, it should only read the
displayed screen, but otherwise I suppose you could just call the
calculate function yourself (it is only a procedure after all), or you
could define a separate query to re-read the record and do the
calculation.

oliv...@zip.com.au

Quote
Oliver TownshendAndrew Cutforth wrote:

 

Re:How to re-calculate a calculated field


Does anyone know how to re-calculate a dataset's calculated fields
without doing a Refresh.

I have a DBGrid that needs to display some additional information
alongside the real data fields.  I have used a TStringList to hold
the extra info and in the OnCalcFields event I look in the
StringList and set the calculated field.

The only way to get it to re-calculate the field is to scroll up and
down the grid or do a Refresh on the dataset.  Refresh is no good
because I might be using a query which could take time.

One possible task I need to do this with is:

I have a grid full of transactions and the user marks against each
transaction how much they want to pay.  I only want to update the
data at the end when I am sure that everything balances up.

Thanks for any help on this.

Re:How to re-calculate a calculated field


In article <31EFD1ED.1...@netcomuk.co.uk>, andr...@netcomuk.co.uk says...

Quote
> Does anyone know how to re-calculate a dataset's calculated fields
> without doing a Refresh.

> I have a grid full of transactions and the user marks against each
> transaction how much they want to pay.  I only want to update the
> data at the end when I am sure that everything balances up.

Since it sounds that you're holding data external to the actual table,
you might try coding the OnClick event to add/subtract/whatever to your
calculations.  Then code the OnBeforePost event to store the
calculations.

Mike

Other Threads