I am seeking some relief from having to specifically check for errors in numerous calls to a class object. What I am trying to avoid having to do is wrap each call in an if statement to see if the call to the object worked successfully.
Is there some way that I can handle the error locally where the error took place, and propagate the error back to the parent so that it in turn goes to its error handler and does not plow onward with further normal LOC's?
Example, I simply want to be able to code like this:
However, if one of those FileWrite calls should fail, I would like that error to be propagated to this code, and for this code to immediately jump to its "On Error GoTo" handler.
Is there a way I can code the FileWrite class method that it would raise to the code using it that there was an error?
Or must I wrap each and every FileWrite call with an if statement? TIA!
Is there some way that I can handle the error locally where the error took place, and propagate the error back to the parent so that it in turn goes to its error handler and does not plow onward with further normal LOC's?
Example, I simply want to be able to code like this:
Code:
'Add the data to the email file
ObjTxtFileUtils.FileWrite (vbCrLf & "Project: " & ObjProjectsTbl.title)
ObjTxtFileUtils.FileWrite ("Product: " & ObjProductsTbl.title)
ObjTxtFileUtils.FileWrite (vbCrLf & "Part Number: " & ObjPartsTbl.partnumber)
ObjTxtFileUtils.FileWrite ("Part Description: " & ObjPartsTbl.title)
ObjTxtFileUtils.FileWrite (vbCrLf & "Completed By: " & Me.complbycontactname)
ObjTxtFileUtils.FileWrite ("Completed Date: " & Me.compldate)
ObjTxtFileUtils.FileWrite ("Vendor: " & Me.vendortitle)
ObjTxtFileUtils.FileWrite ("FA Type: " & Me.fatypetitle)
ObjTxtFileUtils.FileWrite ("PQP: " & Me.pqptypetitle)
ObjTxtFileUtils.FileWrite ("Gage Plan: " & Me.gptitle)
ObjTxtFileUtils.FileWrite ("Comments: " & Me.comments)
Is there a way I can code the FileWrite class method that it would raise to the code using it that there was an error?
Or must I wrap each and every FileWrite call with an if statement? TIA!