0

I have a TDBGrid which shows some calculated fields. I'm use MySQL database.

I need to edit field values of one calculated field called "Date" but I can't. I try to edit other field called "Description" which have StringField type and it worked!

Date is shows modificated DateTime type value which only displays the Day only using DayOfTheMonth method.

How to do this? Is there any methods to edit values of Calculated Field? Help me please...

Thanks in advance.

Jessie M
  • 498
  • 1
  • 9
  • 23

2 Answers2

2

A calculated field is, well, a calculated value. You can't edit a calculated field because it is a read-only value that is the result of performing calculations on other data. You have to instead edit the source fields that the calculated field is using.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
0

You can change the way you calculate the value in OnCalcField(). I think that if you refresh the current record this method gets called again so you can modify it.

Riho
  • 4,523
  • 3
  • 33
  • 48
  • How to refresh the current record as you mean? I've been suggested to eliminate the State property in OnCalcFields event handler but I can't see the changes if OnCalcFields was triggered for second time.. – Jessie M Feb 01 '13 at 10:25
  • Are you trying to trigger the new calculation event inside OnCalcFields? I think the current record can be refreshed via RefreshRecord() or RefreshCurrent() or something similar (I'm not behind my work PC now). – Riho Feb 01 '13 at 12:31
  • No, I don't try to trigger new calc event inside OnCalcFields. I've been refresh the current record but still nothing worked. The OnCalcFields is triggered again but don't recalculates the value. – Jessie M Feb 04 '13 at 05:07
  • IF event is triggered then recalculation of the calclulated value is your responsibility. Maybe you do it incorrectly. – Riho Feb 04 '13 at 06:01