Solved

How to find the error number???

Posted on 2003-11-25
5
476 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:SPIADA
5 Comments
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9821912
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
0
 
LVL 23

Accepted Solution

by:
heer2351 earned 50 total points
ID: 9821915
Shan the form_error code is only invoked when the form that holds this procedure has the focus. Furthermore you have to set the response to acDataErrContinue. So you case statement should work, but since you commented it out you need to add the acDataErrContinue back in:

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

Expert Comment

by:ornicar
ID: 10075106
----------------------------------------------------------------------------------------
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

---------------------------------------------------------------------------------------------
0
 
LVL 32

Expert Comment

by:jadedata
ID: 10100481
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question