Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return Error results from subroutine

Status
Not open for further replies.

MJPPaba

MIS
May 28, 2003
142
GB
If I call a subroutine and the subroutine fails using the internal error trapping, can I pass back to the parent sub an error message or such that can be used later?

sub mdl_parent()
dim myMsg as string
Call mdl_validate1
myMsg = myMsg & 'result from validation 1 error
Call mdl_Validate2
myMsg = myMsg & 'result from validation 2 error
msgbox(myMsg)
end sub

sub mdl_validate1()
on error goto myError
'my code goes here

myExit:
exit sub

myError:
mymsg = error$ & " Problem in validation 1 process" & chr$(13)
end sub

sub mdl_validate1()
on error goto myError
' my code goes here

myExit:
exit sub

myError:
mymsg = error$ & " Problem in validation 2 process" & chr$(13)
end sub


please help

cheers

Matthew

crazy times call for crazy people


CrazyPabs


sometimes I wonder why I even bova...
 
You may consider the Err.Raise method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Unfortunately it doesn't do quite what I want, unless I am mis-understanding your suggestion.

Thanks

Matthew

crazy times call for crazy people


CrazyPabs

Is it lunchtime yet?
 
Your easiest option is to use the err function and store the error as a public variable - this can then be transferred back to your main subroutine and reported back.

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
Thanks Geoff,

I knew it was possible.

Cheers Again,

Matthew

crazy times call for crazy people


CrazyPabs

Is it lunchtime yet?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top