Hi Frederic
If you want ProcChild to consider something of global interest (like "cancel
the rest of the operation" or "do this sinstead") then make it a function
instead of a sub and let the caller do the decision. A function will return
a value of the kind youy declare it as (here Boolean True/False). See if
this little demo makes sense:
Sub ProcParent()
MsgBox "Starting now"
If ProcChild = True Then
MsgBox "We do this"
Else
MsgBox "We do that"
End If
End Sub
Function ProcChild() As Boolean
If Weekday(Date) 4 Then
MsgBox "Weekday too big"
ProcChild = False
Else
MsgBox "Weekday is fine"
ProcChild = True
End If
End Function
HTH. Best wishes Harald
"Frederick Chow" skrev i melding
...
Hi all,
Suppose I have to subroutines, ProcParent and ProcChild. ProcParent calls
ProcChild. For some reasons, I don't want the control to be passed back to
ProcParent after Executing ProcChild. I have searched through the VBA help
and I found that both END statement and STOP statement placed in the
ProcChild could do the job, but they have side effects: END will reset any
module-level variables, which certainly I don't want, and the STOP
statement
will just leave the VB editor in (undesired) break mode. Are there any
other
options? Please advise.
Frederick Chow
Hong Kong.