Advice on Code where it gets long

PNGBill

Win10 Office Pro 2016
Local time
Today, 19:42
Joined
Jul 15, 2008
Messages
2,269
Morning Forum, Access 2000

I am automating emails to be sent with different options on the subject which means we have a 2 dimensional list ie for each Subject option there is still the variable wording etc for each recipient situation.

This would mean the code could get quite long.

Does VBA allow "Go Sub" like the old Basic did??

ie, the main code will have the different Subject Options and then sub code will handle what happens with each Subject choice and then return to the main code to send the email that was constructed in the sub code.

or is this just not possible??

I am also experimenting with PowerShell. Can this be an advantage and combined with vba. ie call a powershell script and then return to the vba code??

This may be "a little knowledge is a dangerous thing" but no sparks from the pc yet:eek:
 
It sounds like you want a function. You might have a function that returned the subject, so in your main code you'd have

strSubject = YourFunctionName()

Code would run to that line, jump over and execute the code in the function, and then come back and continue. Perhaps you want to send the recipient to the function to have it determine the subject? A very basic primer on functions here.

http://www.baldyweb.com/Function.htm
 
Thanks Paul.
I just didn't see Public Functions as the same as Go Sub but I guess they are.
 

Users who are viewing this thread

Back
Top Bottom