Stopping the execution of code

A

Andrea

I feel like this is a silly question but I can't find an
answer.

I am trying to get better at writting more efficient and
easy to read code. In doing this, I am trying to minimize
retesting for the same conditions and duplicating code.
I'm also trying to learn what the "best practice" is for
certain things.

In my main subroutine I need to know if a table already
exists. I use a function, Table_Exists, to test for
this. There are two conditions that would cause this to
be true. If the first condition is true, simply setting
Table_Exists=False works fine. However, if the second
condition is true, I want to put up a message box about a
problem and terminate execution of the code. Is it
possible to stop the code without putting it into break
mode? Is this not good coding?

I realize that I could split this into two separate
functions and solve this problem but it seems silly to
write almost the same code again in the 2nd function. I
could also put this code in the main sub and tell it to
exit the sub if the second condition is true. But this
makes the flow of the code more cumbersome to follow. So,
hence my question above.

I look forward to gaining your wisdom!

Thanks in advance,
Andrea
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top