By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,968 Members | 1,180 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,968 IT Pros & Developers. It's quick & easy.

Exit many procedure with one command

P: n/a
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
Feb 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 15 Feb 2006 02:41:13 GMT, "GGerard" <gg*****@nbnet.nb.ca>
wrote:

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

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


Feb 15 '06 #2

P: n/a
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)

"GGerard" <gg*****@nbnet.nb.ca> wrote in message
news:dx********************@ursa-nb00s0.nbnet.nb.ca...
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

Feb 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.