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


Access 2007 VBA err handling not working

Posted on 2011-02-17
Medium Priority
Last Modified: 2012-05-11
I am building my error catching routines on a new dbase and the error handling does not seem to work in any case. I have my error handling set to BREAK IN CLASS MODE.
Code is standard error handling as below.

The code breaks and displays the error popup.

Public sub some_action()
on Error goto errhandler

 ' some code
exit sub
Resume err1
'some action that logs the error and returns user to 'beginning of program

End Sub

Open in new window

Question by:JP_TechGroup
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
  • 2
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 1000 total points
ID: 34917337
try the setting

break on all errors

and, then

break on unhandled errors
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 1000 total points
ID: 34917526
Besides the setting (which is your main problem), you also want a change in structure a bit:

Public sub some_action()
  on Error goto errhandler

   ' some code
   ' Do cleanup
   exit sub

     'some action that logs the error or handles the error
     Resume Exit_some_Action
     Resume Next

End Sub

Author Comment

ID: 34919733
JD, the code example uses:
exit sub
Resume err1
'action to take
end sub

Is there some reason why the label "err1" should be in the sub before the exit? I've tried it and it makes no difference that I can see.
Also, I have tried all three options (though usually I use break on unhandled errors) with the same result.
Further experimentation shows that this does catch some errors, but not others....
LVL 58
ID: 34920192

  One should only Resume after the error has been handled, not before.  And you don't want to exit without issuing a resume of some type as you leave the error handler active then.


Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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 …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

670 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