I have this running in the before update event of a field on a subform
I am trying to stop a user from entering data then trying to close the form without actually saving the record. The problem is when they click NO and it runs the undo command it gives me an error saying "This Value violates the validation rule for the field or record".
I dont have a validation on this field or the record, I had an input mask which I removed and still getting the error. The field in question is actually the FK record on a junction table but duplicates are okay since the PK for the junction table is unique.
Is there a problem with the code? If not any other ideas?
(posted db, form in question is DateMain form, PSN Entry field, it's 2007 sorry!)
Code:
Private Sub idEmpTbl_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
' specify the message to display
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."
' display the message box
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
' check user's response
If iResponse = vbNo Then
'undo the change
DoCmd.RunCommand acCmdUndo
'Cancel the update.
Cancel = True
End If
End Sub
I am trying to stop a user from entering data then trying to close the form without actually saving the record. The problem is when they click NO and it runs the undo command it gives me an error saying "This Value violates the validation rule for the field or record".
I dont have a validation on this field or the record, I had an input mask which I removed and still getting the error. The field in question is actually the FK record on a junction table but duplicates are okay since the PK for the junction table is unique.
Is there a problem with the code? If not any other ideas?
(posted db, form in question is DateMain form, PSN Entry field, it's 2007 sorry!)