Results 1 to 12 of 12
  1. #1
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290

    Unanswered: on error goto ...

    hello all,

    i have a problem with my MSAccess 2003, and i don't know where to look for :

    i have a simple example:

    Private Function Whatever()
    On Error Goto ErrHandler
    Dim nNum as Long
    nNum = 1 / 0
    exit function
    ErrHandler:
    resume next
    End Function

    i never get in the ErrHandler, just a pop msgbox err 11 ..... End/Debug
    do i miss something, may be a reference ?

    emiel

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    my version:

    Private Function Whatever()
    Dim nNum as Long 'i prefer declarations at the top
    On Error Goto Whatever_ErrHandler 'i prefer labels named specifically local (in reality i use err_Whatever which is clearer (for me))
    nNum = 1 / 0
    Whatever_exit:
    exit function
    Whatever_ErrHandler:
    resume Whatever_exit
    End Function

    meanwhile, back at your question, what happens if you add:
    Private Function Whatever()
    On Error Goto ErrHandler
    Dim nNum as Long
    nNum = 1 / 0
    exit function
    ErrHandler:
    msgbox "Visit ErrHandler:" & vbcrlf & err.number & vbcrlf & err.description
    resume next
    End Function
    Last edited by izyrider; 04-09-06 at 13:26.
    currently using SS 2008R2

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ??is it that your real func is
    private function whatever() as double 'or something

    ...and caller is choking on a null return (i.e. the resume next works fine in the function itself but triggers an unhandled error in caller)

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290

    Red face

    hello Izyrider,

    Your remarks are usually done by me too, but for the simplicity i quickly typed out a simple example....

    well what you suggested i have tried that also that way by a msgbox, tried the debugger, tried a watchpoint, copiled it, but the result is still the same, so i was thinking do i miss a reference or such, attached a printscreen result to see what occurs.

    i also read somewhere in the help file that not all events could be trapped, but division by zero is one which can be trapped, so what now ????
    Attached Thumbnails Attached Thumbnails OnError.gif  
    Last edited by emiel; 04-09-06 at 22:08.

  5. #5
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    hello Izyrider,


    as reaction on :

    '...and caller is choking on a null return (i.e. the resume next works fine in the function itself but triggers an unhandled error in caller)'

    No it not a real function , just an example i use to raise an error to check the errorhandler.

    as you see in printscreen it happens always, if it is direct cmd_click sub, a private or public function/sub, without or with a return value, whatever, it still will not work.

    To me it looks like i can programme it, but it is ignored during runtime.
    emiel
    Last edited by emiel; 04-09-06 at 22:01.

  6. #6
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    when i make a MDE, all is working, so next question why does it not work in design mode?

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Works fine for me (XP). Have you tried stepping through the code and following the path of execution?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    works fine for me (A2K3) too!
    amazing that it compiles to .MDE and then behaves, but it wont work in .MDB

    and if you make a new empty MDB
    add a form
    add a button
    paste your code into the button's _Click (with Exit Sub not Exit Function)

    ???? does that work?

    izy
    currently using SS 2008R2

  9. #9
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    BTW - what is the error message? The number is 11 - what is the description?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  10. #10
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oh - ok. 11 is division by zero
    Testimonial:
    pootle flump
    ur codings are working excelent.

  11. #11
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    aha!

    Alt+F11 (open code window)
    menu: Tools ¦ Options
    ...and what do you see there?

    izy
    Last edited by izyrider; 02-05-08 at 14:24.
    currently using SS 2008R2

  12. #12
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    Hello Pootle Flump, Izyrider,

    Yes Pootle Flump i tried that all, but now with the printscreen of Izyrider, my problem is solved, thanks for the help you both.

    i never have looked there for the solution.

    i changed the setting to : break on unhandled errors,

    instead of : break on all errors.

    regards emiel

Posting Permissions

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