Subject Re: [IBO] How to edit calculated field?
Author Helen Borrie (TeamIBO)
At 09:12 AM 28-01-02 +0000, you wrote:
>(Hope this hasn't been asked before - the search options provided by
>yahoo are not very good).
>
>I would like to edit a calculated field in a TIB_Grid control.
>
>The background is: a table stores a person's age in days (thus its an
>integer field). This is however not very convenient for display, so I
>created three calculated fields to return the person's age in days,
>months, years (calculating with 1y=365d, 1m=30d).
>This works fine.
>
>Now I would like to be able to edit those three fields and then
>calculate back to the age in days and store this in the db.
>
>Anyone can give me a hint
>(a) how to get the calculated fields editable
>(b) on which event to react to update person.age with the entered
>value(s)?

You can't edit calculated fields at all. They can only be changed by modifying the data upon which they are calculated and then calling CalculateFields. What you propose is the "reverse" of this.

You could somehow mirror the contents of the calculated fields into ordinary TEdits, read and validate those in some event handler and use their data to calculate new values for the underlying columns.


regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at www.ibobjects.com