Subject Re: [IBO] Calculated fields
Author Helen Borrie
At 03:10 AM 04-03-01 +0000, you wrote:
>This is probably not only an IBO situation but I have a question
>regarding calculated fields on an IBOTable.
>I have defined a calculated field which is evaluated in the
>oncalcfields event. My problem is that I am getting an
>error 'dataase not in edit mode' every time I assign the calculated
>field a value in the oncalcfield event, when the table's state is

A calculated field ONLY exists as the result of a calculation - you cannot assign a value to it. Calculated fields (whether originating from the database via COMPUTED BY or calculated in client code) are always read-only.

To solve the problem of the real data columns being not editable, if you are using TIBOQuery, instantiate the field object of the calc. field and set its FieldKind to fkCalculated. If you are using TIB_Query, double-click on the query object to open the Fields Editor and set the field's COMPUTED attribute true.



>I can understand the logic (I Think!) behind this from the
>point of view that I am assigining a value to a field from the
>dataseset, which it then attempts to write to the database, My
>question is how do I stop it.
>Is there a way to have the oncalcfield event fire and to be able to
>assign the calculated field value without the table objecting.
>Similar calculated fields work fine in an IBOQuery - but the again
>the result set will not be live.
>Stewart Bourke
>Your use of Yahoo! Groups is subject to

All for Open and Open for All
InterBase Developer Initiative ยท