Board index » delphi » Was a TField object modified?

Was a TField object modified?

Hey folks,

Is there any way, without using cached updates, to know whether a TField
object's value was modfied?

I want to create an audit trail for a table, and on the before post event,
cycle the fields to find the ones that have been modified by the user to add
records into another table.  I know I can keep the values in memory and
check each column manually, but I was hoping for a property that would say a
field was modified.

Thanks in advance for any help.
BlueGI

 

Re:Was a TField object modified?


Hi,

Quote
BlueGI wrote:

> Hey folks,

> Is there any way, without using cached updates, to know whether a TField
> object's value was modfied?

> I want to create an audit trail for a table, and on the before post event,
> cycle the fields to find the ones that have been modified by the user to add
> records into another table.  I know I can keep the values in memory and
> check each column manually, but I was hoping for a property that would say a
> field was modified.

You can determine, if a Field is changed in TDataSource.OnDataChange:

procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
  if Field = Table1Field1 then
    Table2Field1.Value := Table1.Field1.Value;
end;

Ciao, Marco

Re:Was a TField object modified?


If you were to ask me I'd say that has trigger written all
over it.

cbaugh

Quote
BlueGI <giwachowNOS...@bcw-usaNOSPAM.com> wrote in message news:8621vv$ehd21@bornews.borland.com...
> Hey folks,

> Is there any way, without using cached updates, to know whether a TField
> object's value was modfied?

> I want to create an audit trail for a table, and on the before post event,
> cycle the fields to find the ones that have been modified by the user to add
> records into another table.  I know I can keep the values in memory and
> check each column manually, but I was hoping for a property that would say a
> field was modified.

> Thanks in advance for any help.
> BlueGI

Re:Was a TField object modified?


You could try wrinting a single TField.OnChange event, and then connecting
all your TFields to that same event.

--

Alain Quesnel
alainnos...@argosoftware.com

===========

Quote
"BlueGI" <giwachowNOS...@bcw-usaNOSPAM.com> wrote in message

news:8621vv$ehd21@bornews.borland.com...
Quote
> Hey folks,

> Is there any way, without using cached updates, to know whether a TField
> object's value was modfied?

> I want to create an audit trail for a table, and on the before post event,
> cycle the fields to find the ones that have been modified by the user to
add
> records into another table.  I know I can keep the values in memory and
> check each column manually, but I was hoping for a property that would say
a
> field was modified.

> Thanks in advance for any help.
> BlueGI

Re:Was a TField object modified?


Thanks for the replies.  Unfortunately, I cannot use triggers because I also
need to get user information which cannot be obtained on the server side.
What I ended up doing was keeping a
list of field values before the user edits the record, then in the
OnAfterPost event, I compare each field value and figure out which ones have
changed.  It works great, but I was hoping for something easier, or built-in
that I can use over again.  Anway, thanks again.

Quote
"BlueGI" <giwachowNOS...@bcw-usaNOSPAM.com> wrote in message

news:8621vv$ehd21@bornews.borland.com...
Quote
> Hey folks,

> Is there any way, without using cached updates, to know whether a TField
> object's value was modfied?

> I want to create an audit trail for a table, and on the before post event,
> cycle the fields to find the ones that have been modified by the user to
add
> records into another table.  I know I can keep the values in memory and
> check each column manually, but I was hoping for a property that would say
a
> field was modified.

> Thanks in advance for any help.
> BlueGI

Other Threads