Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Piscataway, New Jersey, USA
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with Error Handling (all)

    Hi everybody:

    I've been developing in Access for nearly 6 years, but just recently discovered this helpful method of returning meaningful information about run-time errors, so though I would pass it along to you.

    When you write a procedure, dim a string variable and fill it with the name of the form or module and the event or proc name, for example:

    dim strSource as string
    strSource = "frmMain.Form_Open: "
    Then, on your error trap line, write:

    msgbox strSource & err.description & vbcrlf & AccessError(err.number)

    This will return not only where the run time error occurred, but what you did wrong.

    Happy error trapping!

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help with Error Handling (all)

    I've gone a step further and written the error information to a table, along with the User's name (in multi-user situations).

    It's very helpful to be able to run an error report to see what's gone wrong and why...

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Help with Error Handling (all)

    Actually, if you are running the code from within a form or report (or a class module of any kind), you can get the name of the object by using Me.Name, which is what I generally do in my error handlers. Or if you use a product like MZ-Tools, its error handler tool is very convenient for inserting error handling code into any given routine and the template can be customized to give you exactly the results you want, including the name of the procedure.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •