Checking for changed textboxes

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I need to check which textbox controls on a form have their value changed. I
am using the below code to achieve this.

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If (IsNull(ctl.OldValue) And Not IsNull(ctl.Value)) Or
(IsNull(ctl.Value) And Not IsNull(ctl.OldValue)) Then

End If
End If
Next ctl

Problem is I am getting a "The expression you entered has a field, control,
or property name that Events 2006 can't find" error on the line;

If (IsNull(ctl.OldValue) And Not IsNull(ctl.Value)) Or
(IsNull(ctl.Value) And Not IsNull(ctl.OldValue)) Then

What is the problem and how can I fix it?

Thanks

Regards
 
Examples:

a) An unbound control doesn't have an OldValue.

b) A control bound to an expression, or to a field that is read-only doesn't
have an OldValue.

c) A control bound to a non-existent field (e.g. if you changed the
RecordSource of the form so that the field is no longer present) doesn't
have a Value.
 
Back
Top