Solved

How to find the error number???

Posted on 2003-11-25
5
471 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now