Disregard my last post. I tested this myself and found myself surprised and a little annoyed at Microsoft, it appears that a form validation happens before the field validation which means that you need to catch this on the
Form_Error, sorry for the confusion, but my logic is still correct about before and after updates, the difference is that
Form_Error happens before either.
Here is the code you will need to properly catch this:
- Private Sub Form_Error(DataErr As Integer, Response As Integer)
-
Select Case DataErr
-
Case 2113
-
If Me.ActiveControl.Name = "MyTextBox" Then
-
MsgBox "Invalid date!"
-
Response = acDataErrContinue
-
End If
-
End Select
-
End Sub
This code triggers on
Form_Error, it then checks the error number, which in this case is 2113 which means an invalid entry in a field, then it will check that we are on "MyTextBox", if it is it will give your error message and then continue on.
Also, please make sure the before and after update subs are gone so that you aren't replicating effort.
If you have any questions don't hesitate to ask.
-AJ