AllowBreakIntoCode and Error Handling

Posted on 2006-06-02
Last Modified: 2008-01-09
I have an Access adp project that we use as a front-end to a SQLServer db. In production, I've set the AllowBypassKey and AllowBreakIntoCode properties to False to keep users away from code. Well that works a treat but all unhandled errors now are suppressed - and guess what, the error handling in the Access code is less than superior. So when an unhandled exception occurs and the AllowBypassKey and AllowBreakIntoCode are set, Access ignores the error and the user doesn't know that anything went wrong.
Is there a better way of doing this? Is there some way to implement a generic error handler that handles errors that occur application-wide without have to add "on error" statements everywhere (lazy, I know)?

If this helps, here are all the settings we have when the project is put into production:

    CurrentProject.Properties.Add "AllowFullMenus", True
    CurrentProject.Properties.Add "AllowShortCutMenus", True
    CurrentProject.Properties.Add "StartUpShowDBWindow", True
    CurrentProject.Properties.Add "AllowBuiltInToolbars", True
    CurrentProject.Properties.Add "AllowBypassKey", True
    CurrentProject.Properties.Add "AllowBreakIntoCode", True
    CurrentProject.Properties.Add "AllowToolbarChanges", True
    CurrentProject.Properties.Add "AllowSpecialKeys", True

Is the only solution to turn off AllowBreakIntoCode?

Thanks for any guidance....
Question by:ctudorprice

    Author Comment

    p.s. Access 2002/3 & .adp

    Author Comment

    p.s. again, sorry the code I gave turns everything ON, here's what we actually do:

        CurrentProject.Properties.Add "AllowFullMenus", False
        CurrentProject.Properties.Add "AllowShortCutMenus", False
        CurrentProject.Properties.Add "StartUpShowDBWindow", False
        CurrentProject.Properties.Add "AllowBuiltInToolbars", False
        CurrentProject.Properties.Add "AllowBypassKey", False
        CurrentProject.Properties.Add "AllowBreakIntoCode", False
        CurrentProject.Properties.Add "AllowToolbarChanges", False
        CurrentProject.Properties.Add "AllowSpecialKeys", False
    LVL 65

    Accepted Solution

    Im not aware of any
    as far as I know, all error handling is done per procedure
    the only global level I know off is in bounded forms where u have the OnError event handler

    Its good practice to manage errors anyway

    Where abouts is it failing? perhaps u can consolidate your code and merge functions together, make then have arguments,(+ optional) so it does different things on similar funcs depending on what is passed in
    then put error handling in there
    LVL 65

    Expert Comment

    Another option is to create a generic error handler which all other error handlers call

    so in all your procedures, u have your on erro goto ...

    well in that label

    u can use call a function passing in err.number and err.description, also perhaps the source name (vba, form, procedure etc),
    then log that and display an appropriate message

    LVL 27

    Expert Comment


    you would put ONE "on Error" per SUB, so it isn't a long process,
    and on the error traping use,
    msgbox err.number & vbcrlf & err.description

    this way, all the errors will be shown

    the AllowBypassKey and AllowBreakIntoCode have nothing to do with error handling

    Author Comment

    As I understand it AllowBreakIntoCode does have some effect on error handling in that if there's an unhandled error, it at least allows Access to show the error by showing the VB code when the error occurs... no? I understand it does'nt actually "handle" the error but with it turned off, at least there is an indication of failure in the application.
    Is there no way to implement a generic handler without the "on error" in every sub? The app is BIG and I don't want to have to go through a full regression test cuz I've mucked with almot every sub/function in the entire project. Yes, I know it's good practice to implement on error everywhere... blush, blush... but this thing has been with us for 8 years and about 8^8 developers with not a lot of oversight or standards.
    As to where the app is failing: occasionally all over the place with things like variables being defined as integer and then the underlying SQLServer int gets too big for the VBA/Access integer. With AllowBreakIntoCode turned off and no specific error handling in the sub, Access won't do anything with the error in that the user is not notified.
    If no one has a "glbal error handling" solution, is there somewhere I can get some good code for handling errors in each sub - just in case I have a few weeks spare :). Ideally an
    on error go to errhandler

    call generic_errhandler

    or something - and a generic error handler that will allow users to give us details on where the error occurred and vaguely why?

    LVL 27

    Assisted Solution


    you can use the free:
    which can "Add Error Handler" automatically, besides other things.

    LVL 65

    Expert Comment

    Sorry, I dont think u can have a generic error handler, one per procedure I think

    Im sure you are aware of the options

    on error resume next, goto <label>, etc, there is also gosub, but that is only to a subroutine within a procedure

    Another thing, in all your code modules, do you have

    option explicit

    if not, do that then try a debug/compile

    LVL 34

    Assisted Solution

    Hi ctudorprice,
    I have looked for a global error umbrella too and I never had any success. I decided to at least create one error handler system that I could call like you mentioned. I have one errorlog table, and each function contains an on-error call to the Error_Log function.
        'Action: "Clear" or "IsEmpty" or "Add" or "Show"
        'MessageType: "Error" or "Warning"
        'Message: Message to user
        'CorrectiveAction: .. for user to take
    If you want the code I'd be glad to paste.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    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…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now