Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Detecting a field change

594 views
Skip to first unread message

Ian Branch

unread,
Apr 11, 2001, 5:11:32 AM4/11/01
to
Hi Guys,

I need to reliably detect whether a field has changed as a result of
editing via a TDBEdit so I can write a log record of the date/time, user ID
and new value.

I am playing with BeforeEdit to detect the pre edit value and before
post to detect the 'post' edit value. I compare the two and if different,
write the data to the log file.

To my simple mind this should be OK but it seems to yield inconsistant
results. Sometimes it detects & writes correctly, sometimes not. In
particular it doesn't seem to detect if the field is changed twice in a row.

I prefer to do this at the table level as this is the lowest level and
they are all in a Datamodule.

Any suggestions?

Regards,

Ian

Michael G

unread,
Apr 11, 2001, 8:35:40 AM4/11/01
to
One way it can be done, but you need to be using cached updates and a TQuery
to do it, is to check the "OldValue" and "NewValue" variants in the
"OnChange" event of the TField. It has worked pretty well for me in the
past.

Another way, using a TTable and a TDbEdit is to capture the value of the
value of the TField (TableName.FieldByName('YourField').AsString) in the
OnChange event of the DBEdit and the value of the TField in its OnChange
event. For some reason, the value in the OnChange event of the DBEdit will
have the old value and the OnChange event of the TField the new value.

HTH

"Ian Branch" <bra...@ancc.com.au> wrote in message news:3ad41fdc_2@dnews...

0 new messages