Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111

    Unanswered: On Error Resume Next - apply to all procedures

    Is there a way (a simple way!) to apply "On Error Resume Next" to all procedures?

    I read that is very important to do this when people use Access run-time.

    I would like to hear an opinion from you.

    Thank you.

    Regards.

    Jose

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Who on earth told you that???

    On error resume next, means that whatever error occurs, the code will try to move further, creating new errors - giving no control...

    What you need to do is
    1 - add errorhandling to every routine¨
    2 - adapt the errorhandler to the needs of the routine.

    The simple/minimum errorhandling is demonstrated when using the Access wizards, and consists of something like this:

    private sub mysub()
    ' declarations
    on error goto myerr
    ' usefull code

    myexit:
    ' some releasing of object variables, perhaps?
    exit sub

    myerr:
    msgbox err.description
    resume myexit
    end sub

    There's a third party tool, that I think would be able to implement some errorhandling pro each sub, but I think it will be on a sub by sub basis. MZTools, is the name, but again, rather use the default errorhandler template from it, than on error resume next.
    Roy-Vidar

  3. #3
    Join Date
    Nov 2004
    Posts
    32
    I have to agree with Roy on this one. To be honest I'd rather have Access fall over than store incorrect/inaccurate data.

    At the least you should have some sort of error message displayed to the user (I used to include my extension number for some subroutines) and, a resume next point, with some sort of clean up if necessary (possibly resetting global variables if you use them).

    I have used simple resume next in very limited situations when there only seemed to be one possible error, and then it didn't make any difference to the data being stored.

  4. #4
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111
    Quote Originally Posted by RoyVidar
    Who on earth told you that???
    "If you are using a Run-time environment, then error
    trapping ALL procedures is not just important, it is VITAL." - Roger Carlson

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    it is essential to trap errors, otherwise runtime falls over.

    but
    on error resume next
    doesn't "trap" errors, it pretends they didn't happen.

    correct error handling requires much much more to ensure your code makes the right decisions about what to do next when something fails.

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Should have added an emoticon at the end of that line, I guess. Sorry, no offence meant!

    izyrider's explanation addresses the same, but in a much more elegant way.
    Roy-Vidar

Posting Permissions

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