Hello Guys,
I am in need of aid, how to use the function in TZQuery 'NewValue' and 'OldValue'. I need to upgrade the value is changed.
Thanks for the help.
Edson
TZQuery 'NewValue' and 'OldValue'
-
- Fresh Boarder
- Posts: 16
- Joined: 06.12.2006, 15:24
- Location: Perth - Western Australia
- Contact:
Re: TZQuery 'NewValue' and 'OldValue'
Could you clarify further? How to use NewValue and OldValue?
http://stackoverflow.com/questions/1971 ... as-streams
function FieldChanged(DataSet: TDataSet; FieldName: string): Boolean;
var
fld: TField;
begin
fld := DataSet.FieldByName(FieldName);
if fld.IsBlob then
Exit((fld as TBlobField).Modified);
if (fld.OldValue = Null) and (fld.NewValue = Unassigned) then // This happens when a NULL field does not change
Exit(False)
else
Exit(fld.OldValue <> fld.NewValue);
end;
http://stackoverflow.com/questions/1971 ... as-streams
function FieldChanged(DataSet: TDataSet; FieldName: string): Boolean;
var
fld: TField;
begin
fld := DataSet.FieldByName(FieldName);
if fld.IsBlob then
Exit((fld as TBlobField).Modified);
if (fld.OldValue = Null) and (fld.NewValue = Unassigned) then // This happens when a NULL field does not change
Exit(False)
else
Exit(fld.OldValue <> fld.NewValue);
end;
Re: TZQuery 'NewValue' and 'OldValue'
Had tried to do this way In Event "BeforPost" the query:
Note: I need to compare a value if the value changes I perform a procedure:
if qryForm.State in [dsEdit] then
qryFormvlr_serv.OldValue;
if qryFormvlr_serv.OldValue <> qryFormvlr_serv.NewValue then
begin
verifica_status;
end;
Note: I need to compare a value if the value changes I perform a procedure:
if qryForm.State in [dsEdit] then
qryFormvlr_serv.OldValue;
if qryFormvlr_serv.OldValue <> qryFormvlr_serv.NewValue then
begin
verifica_status;
end;
-
- Fresh Boarder
- Posts: 16
- Joined: 06.12.2006, 15:24
- Location: Perth - Western Australia
- Contact:
Re: TZQuery 'NewValue' and 'OldValue'
I use something like this, ZQuery, MySQL
Code: Select all
OnBeforePost
var
OldValue : variant;
begin
if Self.State in [dsEdit] then
begin
if not FieldByName('taskstatusid').IsNull then
begin
OldValue := FieldByName('taskstatusid').OldValue;
if VarIsOrdinal(OldValue) then
begin
if FieldByName('taskstatusid').AsInteger <> VarAsType(OldValue, VarType(OldValue)) then
begin
// Status has changed.
end;
end;
end;
end;