Solved

How to find the error number???

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

734 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