Steve R.
Retired
- Local time
- Today, 13:34
- Joined
- Jul 5, 2006
- Messages
- 5,746
I have some text boxes that require that the user enter a date. If a mistake is made, ACCESS gives the useless message "that the value entered is not appropriate for the field." To get around this, I thought that using "DoCmd.SetWarnings False" in the textbox's before update event would work. That did NOT work.
What did work, is using the forms "OnError" event along with "Response = acDataErrContinue" See the sample code below.
What did work, is using the forms "OnError" event along with "Response = acDataErrContinue" See the sample code below.
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim ctlCurrentControl As Control
Dim strControlName As String
Dim intResponse As Integer
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
Select Case DataErr
Case 2113
MsgBox "You have entered an incorrect date; " & strControlName & Chr(13) & "The error code is: " & DataErr
Response = acDataErrContinue
Case Else
MsgBox "An unknown error occured. The error code is: " & DataErr
End Select
End Sub