Check to see if a field has changed

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Hi All,

I have a form with several fields that pulls in one record. When the user
clicks a command button to save updates to the record, I want to be sure
that they've modified a notes field. I know I can check the entire form
using me.dirty, but am unsure as to how to check a single field.

Any help you can pass along is appreciated.

Thanks & Ciao,

Tony
 
You can use the Tag property of the Notes field to hold a
flag after a change is made. For instance, in the OnChange
event of the Notes field put the following code:
Me!NotesField.Tag = "changed"
Then, in the OnUpdate event of the form put:
If Me!NotesField.Tag = "changed" Then
' your code here
...
etc.
End If
Also be sure to initialize the tag property in the
OnCurrent event as follows:
Me!NotesField.Tag = ""

Of course if the change is undone, then you will have to
undo the flag which would require additional programming.
 
Compare the Value of the control to its OldValue:

Private Sub Form_BeforeUpdate(Cancel As Integer)
With Me.Notes
If .Value = .OldValue Then
MsgBox "You don't fool me!"
Cancel = true
End If
End With
End Sub
 
Jack,

Thanks for the info. I went with Allen's suggestion since the code is a bit
shorter.

Thanks for the reply,

Tony
 
Back
Top