Don't need a function. The code to use with a public Boolean Variable is;
In Called Procedure:
'yada yada
'Something bad here
Flag = False
Exit Sub
'All was good, continue
'yada yada
Flag = True
End Sub
In your Master Procedure
'Yada Yada
Flag = False
Call SumSub()
Do Events
If Not Flag Then
Call Sub OOPS()
Stop Procedure.Me
End If
'yada yada
And
Sub OOPS(Parameters)
Messages = "Warning! Warning! Danger Will Robinson!"
'Yada Yada
In my opinion:
Boolean Flags are about the only variable Types that should be used As Public. If you need Public Properties, you should use Property Procedures.
Flags themselves don't have to be just Booleans.
The Setting Procedure
Success = Me.Name & "True" 'Since the name is expected to be known
'OR
Success = Me.Name & ErrorCode
You can create a User Defined Type (UDT)
Type tySuccess
suBool As Boolean
suCaller As String(32)
suError_Code As Long
suMsg As String(64)
End Type
Public Success As tySuccess
To set it
With Success
.suBool = True
.suCaller = Me.Name
.suMsg = "Yay!"
End With
Read it again, I did say "About." Those more compex structure should only be used when it is critical that more than a boolean value be used. It's just a "Bad Thing."
A Public StringVar can be real handy because it will carry boolean values, and once in a while you may want it to carry some string value. Until that happens you can just
StringVar = True
'OR
StringVar = BooleanVar
'OR
If StringVar Then