Results 1 to 5 of 5

Thread: Global Error Handler

  1. #1
    Guest

    Question

    I'm using an Access 2000 (ADP) project, and I'm trying to create a global error handler without having to to do the following in each Sub and Function:

    On Error GoTo Error_Handler_1

    'Code here


    :Exit_1
    exit sub


    :Error_Handler_1
    Call Handle_Error
    Goto Exit_1

    Public Sub Handle_Error()
    msgbox "An error has just occured"
    end Sub

    Anybody know how to do this?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    If memory serves me here, the main sub's errorhandler stays in effect for all subs called from the main sub.
    If you write your app as subs called from the main then you only need one error handler.

    I'm sure lots of people will correct me if I have not understood the concept and this is not the case.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest

    Unhappy

    Hi Wool1,

    I haven't used Access 2000 but since it's all based on VB,
    I believe you are out of luck here.

    You can write a global error handler but to do it properly
    reaches into the realms of rocket science--and you still
    don't get away from On Error Goto's in ALL your Subs
    and Functions.

    Maybe someone else knows a way, but I wager you'll have
    to wait for VB7 (or VB.Net) for some better way of doing
    it.

    HeSaidJoe says to keep it simple and write your app as
    sub's called from Main(). If your routine get's anything
    near level 1 complexity on a scale of 1 to 10, you start
    losing track of which routine caused which error and where
    to resume back to. A global error routine in Main() is Ok
    if all you ever want to do is abandon the routine that
    caused the error and report it, but if you want to recover
    gracefully and resume the routine that caused the error
    (let's say the routine is 10 calls deep), it starts getting
    very messy indeed.



  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    k4plus:
    Quite agree with that, I was just stating how it would work if my memory served me correctly, and I wasn't even sure of that till I tested it afterward.
    The level of complexity (depending on what you are doing with the application), could be simple or so severe it isn't worth the time to even think about it.

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    Guest

    Re: <?>

    Originally posted by HeSaidJoe
    k4plus:
    Quite agree with that, I was just stating how it would work if my memory served me correctly, and I wasn't even sure of that till I tested it afterward.
    The level of complexity (depending on what you are doing with the application), could be simple or so severe it isn't worth the time to even think about it.

    No offence meant HeSaidJoe, and I think your memory serves you very well indeed...



Posting Permissions

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



Click Here to Expand Forum to Full Width