+ Reply to Thread
Results 1 to 7 of 7

Error Numbers in Error/Exit handlers

  1. #1
    Registered User
    Join Date
    11-09-2016
    Location
    London, England
    MS-Off Ver
    2010/2016
    Posts
    72

    Error Numbers in Error/Exit handlers

    Hi,

    I am doing this:

    Please Login or Register  to view this content.
    The problem is Err.Number is always 0 in the ExitHandler, even if if gets there via Resume ExitHandler in ErrorHandler, so the form always closes.

    I only want the form to close if the error is really 0.

    Thanks
    Last edited by ldoodle; 05-19-2018 at 03:45 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,012

    Re: Err

    .
    Please Login or Register  to view this content.
    What happens if you delete the "On Error Resume Next" line ?

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Err

    Please take a few minutes to reread the forum rules about thread titles, and then amend yours accordingly.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Err

    This line
    Please Login or Register  to view this content.
    resets the error, hence the error number will then be 0
    For more info have a look here http://excelmatters.com/2015/03/17/on-error-wtf/

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,645

    Re: Err

    Welcome to the forum! Please take a moment to re-read forum rule #1 and then amend your thread title to something that better explains your problem. Changing your thread title is not optional, which means you must change it. Thanks!

    • Use concise, accurate thread titles.
    • Your post title should describe your problem, not your anticipated solution.
    • Use terms appropriate to a Google search - poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice tell us nothing.
    • Responding to a request to change your thread title by doing so is mandatory.

    To change a title go to your first post, click EDIT then Go Advanced and change your title.

    No help to be offered, please, until the OP complies with this request.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    11-09-2016
    Location
    London, England
    MS-Off Ver
    2010/2016
    Posts
    72

    Re: Error Numbers in Error/Exit handlers

    Thanks all. I did try removing On Error Resume Next but it didn't change anything.

    Fluff13 is right - the error number is always there in the error handler. I found a better way of deciding to close the form or not by checking if the current MailItem is Inspector or ActiveExplorer.

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Error Numbers in Error/Exit handlers

    Glad you got it sorted & thanks for the feedback

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1