Re: Modify the Default Error Msg

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Tom,

this code has a syntax problem on the 2nd line

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If Me.CASELOAD.Text = Not Null Then
MsgBox "A caseload type must be entered in order to continue.", vbCritical,
"CASELOAD Error Message"
Exit Sub
End If
End Sub

This line
If Me.CASELOAD.Text = Not Null Then

rewrite like this

If Not IsNull(Me.CASELOAD) Then

Jeanette Cunningham

"TomP" <TomP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:203A13F2-FE77-4BFE-9B9A-331D79F5FDB6@xxxxxxxxxxxxxxxx
The argument from the Form_Error works. But, I don't understand why it
doesn't work when I use the command button. I copied/paste the text from
the
form_error and added to the Add New Record button and this is the error I
get
"You can't go to the specirfied record."

Private Sub Command182_Click()

Const conErrRequiredData = 3314

If DataErr = conErrRequiredData Then
MsgBox "Please ensure that you enter a caseload type before you
continue!", vbCritical, "Caseload Type Error Message"
Response = acDataErrContinue
Else
'Display a standard error message
Response = acDataErrDisplay
End If

On Error GoTo Err_Command182_Click

DoCmd.GoToRecord , , acNewRec

Exit_Command182_Click:
Exit Sub

Err_Command182_Click:
MsgBox Err.Description
Resume Exit_Command182_Click

End Sub

Thank you for your help!

Tom

"Allen Browne" wrote:

In Form_Error, include the MsgBox for the message you want.

Then set the Response argument to suppress the built-in message.
On-line help for the Error event (in the Code window) will give details.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"TomP" <TomP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:094BA623-B7AF-4B97-8B3D-06584679821A@xxxxxxxxxxxxxxxx
I tried the script as shown below and for some reason I get the same
default
error message. I even tried the code as shown below to display the
actual
error number and nothing happens.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Debug.Print "DataErr = "; DataErr
End Sub




.



Relevant Pages

  • RE: On Form Error: MsgBox
    ... just the form) I want it to prompt the first prompt in the code below then ... Can you help me modify the below code to prevent the above error message from ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ...
    (microsoft.public.access.formscoding)
  • Current Year Data Validation
    ... the field but that wouldn't work because I kept getting an error message ... Private Sub TADate_AfterUpdate ... If Response = vbYes Then ' User chose Yes. ... Else ' User chose No. Cancel Event and remain on Current Field. ...
    (microsoft.public.access.forms)
  • Re: Modify the Default Error Msg
    ... continue!", vbCritical, "Caseload Type Error Message" ... Response = acDataErrContinue ... On-line help for the Error event (in the Code window) will give details. ... Private Sub Form_Error ...
    (microsoft.public.access.forms)
  • Re: Unfriendly error message in date field
    ... Use the form's Error event. ... Private Sub Form_Error(DataErr As Integer, Response As Integer) ... > cannot get in front of that error message. ...
    (microsoft.public.access.formscoding)
  • Re: Error 3265: Item not found in this collection
    ... NewData As Variant) As Integer ... Private Sub AssignedCAD_NotInList(NewData As String, Response As ...
    (microsoft.public.access.formscoding)