This topic is locked

How to tell if a particular field has changed

1/26/2006 8:11:05 AM
ASPRunnerPro General questions
B
blacksuperman author

Sergey,

I'm using 4.0 beta and trying to detect if a certain field has changed. Is there a way to use the Before record updated and Afer record updated to tell if there is a difference? I make the assumption that I would have to somehow capture the value for the field in question in the "before" event then do a query to compare the values, but I'm not sure on the scope of the variable that I would set in the before event. Any ideas?
Thanks,

Dave

admin 1/27/2006

Dave,
here is some sample code you can try.

Function BeforeEdit(dict, where)
set rstmp = Server.CreateObject("ADODB.Recordset")

rstmp.Open "select * from TableName where " & where, dbConnection
if dict("FieldName")=rs("FieldName") then

' field value hasn't changed

else

' field value has changed

end if
rstmp.Close : set rstmp=nothing
BeforeEdit = True
End Function