Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to find the error number???

Posted on 2003-11-25
5
Medium Priority
?
483 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

660 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