check whether a field has changed?

spinkung

Registered User.
Local time
Today, 13:17
Joined
Dec 4, 2006
Messages
267
Hi

i have an OnExit event from a text box in a subform (bound) that insert's the record into another table. Can i check whether the field being exited has changed from it's original value?? If the value hasn't changed i don't want to run the insert.


Thanks
 
1. Don't use the On Exit event.

2. Use the Before Update event. It won't fire unless something has changed.
 
but controls have an old value property

you can say something like (in the beforeupdate event)

Code:
if textbox=textbox.oldvalue then
   'code to ignore this ...
end if
 
but controls have an old value property

you can say something like (in the beforeupdate event)

Code:
if textbox=textbox.oldvalue then
Code:
[B]  'code to ignore this ...[/B]
[B]end if[/B]
Now, while that is true - the OP just asked:
If the value hasn't changed i don't want to run the insert.
and therefore, simply using the Before Update should be simple enough because it won't fire if nothing has changed. The same goes for the control's Before Update event. The form's Before Update event would be dependent on ANY change to a bound field on the form whereas the CONTROL'S Before Update event would deal explicitly with that control.
 
i am not sure about that, bob

i thnik if you edit a control, but leave it unchanged, it still dirties the record - and you still get an update process.
 
Yeah, I guess even if you change it back to the old value it does go through that. So you are right, you would need to use

Code:
If Me.ControlNameHere.OldValue <> Me.ControlNameHere Then
       ' Do something here to notify of a change
End If
 

Users who are viewing this thread

Back
Top Bottom