Hello
Is there a way to exit all running procedures with one command?
Sometimes a procedure(1) will call another procedure(2) which could call a
third procedure(3) and what I would like to do is give a command in
procedure(3) that would exit all three procedure without returning to
procedure(1) and procedure(2)
Example: I have hundreds of procedures and all of them call a function
(MyErrHandle) to handle any error that might happen during the procedure.
Private Sub Command0_Click()
On Error GoTo err_Handle
Exit Sub
err_Handle:
Call MyErrHandle
Resume Next
End Sub
Normally MyErrHandle will log the error and sometimes display a message and
then Resume Next upon returning from MyErrHandle. For certain errors,
however, I would like to exit the Command0_Click procedure instead of Resume
Next.
I know I could write the following code after Call MyErrHandle
Exit Sub
err_Handle:
Call MyErrHandle
If Err.Number = 3084 then
Exit Sub
Else
Resume Next
End if
End Sub
But if I could stop or exit the Command0_Click procedure from the
MyErrHandle or not return to Command0_Click from MyErrHandle it would save
me from going through all my hundreds of procedures and retype more error
handling codes.
Also the command has to not upset the functioning of the application to much
and requiring the application to be shut down and reopened.
I am using MSACCESS 2000
Thanks
G Gerard
Tom van Stiphout - 15 Feb 2006 04:15 GMT
Well, if you ONLY have an error handler in the toplevel procedure, and
an (unhandled) error occurs in a subprocedure, your toplevel error
handler will get control. So effectively you have exited all running
procedures, with zero commands :-)
-Tom.
>Hello
>
[quoted text clipped - 59 lines]
>Thanks
>G Gerard
david epsom dot com dot au - 15 Feb 2006 07:30 GMT
There is no good way to do it like that.
You can use End to exit all code, it also clears all variables.
You can use err.raise to go to the next error handler - you can record the
error, but you should only report the error at the top level.
(david)
> Hello
>
[quoted text clipped - 59 lines]
> Thanks
> G Gerard