I use the code below when a form is closed to either save or undo changes. However I only want the msg box to appear if there have been any changes to the record that the form is based on, if there aren't any changes then it will just docmd.close without the msgbox. How would I check if there have been any changes to the record? I think you have to use 'Dirty' but im not really sure how to use it.
Private Sub CLoseUR_Click()
Dim strMsg As String, strTitle As String
strMsg = "Do you want to save changes?"
strTitle = " Save Changes?"
If ValidateForm Then
Else
If MsgBox(strMsg, vbQuestion + vbYesNo, strTitle) = vbNo Then
Me.Undo
DoCmd.Close
Else
DoCmd.Close
End If
End If
End Sub