Subject Re: [IBO] Calculated field column total?
Author Paul Hope

> Yes, have two calculated fields. One for storage purposes and the other to
> hold your real value.

I felt a bit silly after posting the original message because I realised
that calculated field values are not persistent, they are not stored in the
buffer and are only calculated on request (I think). It is therefore not
possible to access the previous value of a calculated field and therefore
determine the amount of change. Also if a row is deleted (by a master
dataset and a refresh) there is no event to allow the row value to be
removed from the total.

I think the only option is to sum the whole buffer after each refresh. It
would be neater if there was an event to hang the calculation on rather than
having to call it in code after any refresh or open call.

This is one of the differences I found between IBO and the BDE. In the BDE
AfterOpen meant 'after the data is retrieved and you can now process it' - I
don't think IBO works the same way (unless some flags cause it to) and the
only way to get equivalent functionality is to code the after open stuff
after the call to Open/refresh etc. I would have thought an
AfterGettingTheData event would be very useful (please tell me if it already
exists and I've missed it :-))


> Jason Wharton
> CPS - Mesa AZ
> ----- Original Message -----
> From: "Paul Hope" <paulhope@...>
> Newsgroups: egroups.ibobjects
> To: <>
> Sent: Wednesday, February 27, 2002 4:45 AM
> Subject: [IBO] Calculated field column total?
> > Hi
> >
> > I want to display a total of a calculated field for a read only dataset
> > displayed in a grid. I could fire off another query on the server
> it
> > to recalculate a total every time a row changes in the displayed
dataset -
> > but this seems very inefficient.
> >
> > What I was hoping to do is in CalculateField
> > subtract ARow.ByName('MyCalculatedField').asCurrency from my total
> > calculate the new value of MyCalculatedField
> > add the new value to my total
> >
> > Unfortunately reading the calculated field value before it is set
> > work. It seems to return the value it had calculated for the previous
> row.
> >
> > I have also tried summing the field values in the buffer (having set
> > Fetchall to true) but I havn't found an appropriate event to attach this
> > to - 'AfterRefresh' would be nice.
> >
> > Any Ideas?
> >
> > Regards
> > Paul
> IB Objects - direct, complete, custom connectivity to Firebird or
> without the need for BDE, ODBC or any other layer.
> - your IBO community resource for Tech Info
> keyword-searchable FAQ, community code contributions and more !
> Your use of Yahoo! Groups is subject to