Exit Sub in called sub (1 Viewer)

Wysy

Registered User.
Local time
Today, 05:21
Joined
Jul 5, 2015
Messages
333
Hi,
I have a form with public sub than contain an exit sub statement. I want to call that sub in some other events of the same form. however when i do so the called sub works except the exit sub statment. It is embedded in an if option. Why the exit sub does not work if it is in a called sub?
thank you
 

Wysy

Registered User.
Local time
Today, 05:21
Joined
Jul 5, 2015
Messages
333
I did. It is a conditional statement. Everything works as expected, only the exit sub statement fails.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:21
Joined
Sep 21, 2011
Messages
14,038
I did. It is a conditional statement. Everything works as expected, only the exit sub statement fails.
So it actually gets to that line and just moves on to the next line?
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:21
Joined
Sep 21, 2011
Messages
14,038
So just to be clear. The sub is in a module, and is being called from various events of the form.
OR the Public sub is inside the form?

If the second option, have you tried as the first option? Just trying some tests I would perform, if it was me.
Failing that, can you upload the DB so we can see if it happens to us, plus instructions on how to start the process.
 

strive4peace

AWF VIP
Local time
Today, 07:21
Joined
Apr 3, 2020
Messages
1,003
hi @Wysy

> Why the exit sub does not work if it is in a called sub?

Exit Sub only exits the current procedure, not the whole process. If you want the calling sub to exit as well, you need to add Exit Sub after you call it. I don't know your logic ... so perhaps there is more to this. Perhaps you can post the calling code?
 

Wysy

Registered User.
Local time
Today, 05:21
Joined
Jul 5, 2015
Messages
333
Sorry, i away. I understand: it is necessary to add an exit to the sub where the calling happens.
Thank you.
 

strive4peace

AWF VIP
Local time
Today, 07:21
Joined
Apr 3, 2020
Messages
1,003
Sorry, i away. I understand: it is necessary to add an exit to the sub where the calling happens.
Thank you.
you're welcome. Does that mean you changed it and now it works?

or is the issue that Exit Sub is there? If so, put a Stop statement in, temporarily, before the Exit Sub to verify it actually isn't working. My guess is that code isn't going to that statement. Is it inside an IF block?
 

Users who are viewing this thread

Top Bottom