Check to see if a field has changed

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
 
J

Jack

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.
 
A

Allen Browne

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
 
T

Tony

Jack,

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

Thanks for the reply,

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top