Link to home
Start Free TrialLog in
Avatar of SPIADA
SPIADA

asked on

How to find the error number???

Hi,
    I would like to display a custom error message.I used the following subroutine.But still the MS-Access's default Error message overrides my custom message.In other words,this routine form_error is not at all invoked.I used an ErrObject variable also.But still MS-Access's default error message keeps popping.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
    msgbox DataErr
    'Select Case DataErr
    '     Case xxxx
    '          MsgBox "My Error Message for XXXX"
    '          Response = acDataErrContinue
    '     Case Else
    '          Response = acDataErrDisplay
    'End Select
End Sub

      I would like to know how to trap the error number.After trapping which error function shud i use to display my custom error message????Suggstions please

Thanks
Shan
Avatar of svenkarlsen
svenkarlsen

Hi Shan,
Here's a sample of an error trap getting the  error number (err.Number):


Error Handler:
Err_skAnalyzeSQL:
    MsgBox "An error occurred in the function: skAnalyzeSQL." & vbNewLine & _
        "Err # - msg: " & Err.Number & " - " & Err.Description, vbCritical, _
        "Function Error"
    Resume Exit_skAnalyzeSQL


Here's how I raise an error of my own:

If Len(Nz(skFieldNameSetIn)) = 0 Then
    ' If no data, complain!
    Err.Raise 1000, "skCreateTable", _
    "No Field name(s) supplied in call to skCreateTable"
End If

Kind regards,
Sven
ASKER CERTIFIED SOLUTION
Avatar of heer2351
heer2351

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
----------------------------------------------------------------------------------------
This question has been abandoned and needs to be finalized.
 You can accept an answer, split the points, or get a refund (information at http:/help.jsp#hs5)
  If you need a moderator to help you, post a question at Community Support (http:/Community_Support/)

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

ornicar
Cleanup Volunteer

---------------------------------------------------------------------------------------------
Avatar of jadedata
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: heer2351 {http:#9821915}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jadedata
EE Cleanup Volunteer