+ Reply to Thread
Results 1 to 3 of 3

How to look backwards from a userform to the calling procedure's error handling

  1. #1
    Registered User
    Join Date
    04-02-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    38

    How to look backwards from a userform to the calling procedure's error handling

    Pretty much exactly as the title says -- can anyone suggest how I can, from within a userform with no error handling, look backwards to the "calling" procedures' error handling? I say "calling" because I understand (or I think I understand) that after firing UserForm_Initialize(), the call stack is going to end, or least break, once it finishes executing it's current line of procedure calls and waits for user interaction. And after user interaction fires an event and there is error generating code in that event or in the line of procedure calls initiated by that event, the furthest down the stack VBA will go to find an error handler is event that fired from the user interaction.

    As I understand this (however accurate it may be), it makes sense why the error generated by the user event won't go back to the error handler in the "calling" procedure all the way at the bottom of the stack.


    So my question is; is there any way to get around this break in the call stack and tie the error generated by the user event back to the "calling" procedure's error handler, without introducing new error handling? The reason I ask is because I have a project with several complex userforms (with a lot of controls and code) and I don't want to have to introduce error handling in every procedure that needs it just because VBA won't naturally go back to the calling procedure's error handling (as my mind considers the calling procedure to be).


    Does that make sense?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to look backwards from a userform to the calling procedure's error handling

    Hi,

    Does Chip's site http://www.cpearson.com/excel/errorhandling.htm help?
    Particularly the pre-penultimate paragraph "Error Handling With Multiple Procedures".
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How to look backwards from a userform to the calling procedure's error handling

    No, there is no way to circumvent the break in the call stack, I'm afraid.
    Remember what the dormouse said
    Feed your head

+ 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