Checking for value changed

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

John

Hi

When a user has modified a text box how can I check if the value has
actually been changed form what it was and the value is not null or empty?

Thanks

Regards
 
Until the record is saved, you can compare the Value of a control to its
OldValue.

This example tests whether a control changed at the last possible moment
before the record is saved:

Private Sub Form_BeforeUpdate(Cancel As Integer)
With Me.[YourControlNameHere]
If (.Value = .OldValue) OR (IsNull(.Value) AND IsNull(.OldValue))
Then
Debug.Print "unchanged"
Else
Debug.Print "Changed from " & .OldValue & " to " & .Value
End If
End With
End Sub
 

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

Back
Top