Full Version: Replace an Access error message for a custom one
UtterAccess Forums > Microsoft® Access > Access Forms
Cabimero
i have to replace the message box from Access on error 3314 for a message box with a custom message. I tried on the Private Sub Form_Error the following without results:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
'Dim Msg As String
On Error GoTo 0
On Error Resume Next
DoCmd.SetWarnings False
If DataErr = 3314 Then
'Msg = MsgBox("Ha dejado de llenar algun campo obligatorio en amarillo. Por favor coloque la información solicitada para poder continuar", vbCritical)
'SendKeys "{ESC}"
[Reporte #].SetFocus
End If
End Sub
But I still have the error message..
Please help...
maxmangion
Hi,
Try
CODE
On Error Goto Err_Handler
'your sub code is here
Exit_Sub:
Exit Sub
Err_Handler:
If err.number = 3314 Then
'code goes here
Resume Exit_Sub
End If
Cabimero
did not work....
Cabimero
The code is:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
On Error GoTo Err_Handler
Exit_Sub:
Exit Sub
Err_Handler:
DoCmd.SetWarnings False
If DataErr = 3314 Then
'Msg = MsgBox("Ha dejado de llenar algun campo obligatorio en amarillo. Por favor coloque la información solicitada para poder continuar", vbCritical)
[Reporte #].SetFocus
Resume Exit_Sub
End If
End Sub
HiTechCoach
This previous post may help:
Is there any reason(s) for Microsoft's default error handling?
Cabimero
Did not...
Cabimero
Why if i say: docmd.setwarnings false i still se the MS error message?
HiTechCoach
Since i can not see all the other code in the form and do not have a clear understanding about exactly what you are trying to do, it will be have to say if your method will work, or how to fix it.

What would be very helpful it to post a sample database with the form and sample data so that we can see the form and what you are trying to do.

I do see a problem in the you are not setting the vale for 'Response"

You need something like:


CODE
Private Sub Form_Error(DataErr As Integer, Response As Integer)
nbsp;   Msgbox "An unexpected error has occurred in the form.  " & _
        "The error description is " & err.description
    Response = acDataErrContinue   '  <<<<< you need this
End Sub




Hope this helps ..
Edited by: HiTechCoach on Thu Jul 31 20:10:47 EDT 2008.
Cabimero
Worked Out!!!
reat...Thanks a lot!
HiTechCoach
You're welcome!
Glad we could assist.
uarulez2.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.