Exit Sub in called sub (1 Viewer)

Wysy

Registered User.
Local time
Yesterday, 20:24
Joined
Jul 5, 2015
Messages
291
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:24
Joined
Sep 21, 2011
Messages
10,561
Have you walked through the code line by line?
 

Wysy

Registered User.
Local time
Yesterday, 20:24
Joined
Jul 5, 2015
Messages
291
I did. It is a conditional statement. Everything works as expected, only the exit sub statement fails.
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:24
Joined
Sep 21, 2011
Messages
10,561
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?
 

Wysy

Registered User.
Local time
Yesterday, 20:24
Joined
Jul 5, 2015
Messages
291
Yes. The sub does not quit.
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:24
Joined
Sep 21, 2011
Messages
10,561
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.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 23:24
Joined
Jan 23, 2006
Messages
14,320
Show us the code.
 

strive4peace

AWF VIP
Local time
Yesterday, 22:24
Joined
Apr 3, 2020
Messages
861
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?
 

Users who are viewing this thread

Top Bottom