Steve R.
Retired
- Local time
- Today, 11:10
- Joined
- Jul 5, 2006
- Messages
- 4,617
I would like to display my own error message instead of the Access error message which is vague. I have a DATE field. If a user enters an invalid date access gives the message "The value you entered isn't valid for this field". I would like it to say "Please enter a valid date". The code below is set to operate on the "BEFORE UPDATE" event. There appear to be two issues.
1. The Access error message is not suppressed.
2. The error subroutine below never seems to be triggered since I do not get the "Hi" message.
First: Is the "BEFORE UPDATE" event the correct point at which to check the validity of data?
Second: Is this one of the Access messages that simply can't be turned off?
1. The Access error message is not suppressed.
2. The error subroutine below never seems to be triggered since I do not get the "Hi" message.
Code:
Private Sub comments_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Comments_BeforeUpdate
DoCmd.SetWarnings False
MsgBox "Before Update Event Occured" <=Revised message box to be added after it works.
Exit Sub
Err_Comments_BeforeUpdate:
DoCmd.SetWarnings False
MsgBox "HI" <=Revised message box to be added after it works.
DoCmd.CancelEvent
DoCmd.SetWarnings True
Exit Sub
End Sub
First: Is the "BEFORE UPDATE" event the correct point at which to check the validity of data?
Second: Is this one of the Access messages that simply can't be turned off?