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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error handler problems

Status
Not open for further replies.

Luis939

MIS
Feb 28, 2003
453
US
In my first sub i have

on error goto next

thats fine, but when that sub calls a 2nd sub, the 2nd sub still inherits that line so that if there is an error in that 2nd sub it ignores it and doesnt catch it. How do i make it so that the normal error handler works in new subs called, thanks!!
 
Hi,

Try setting On Error before calling your sub...
Code:
Sub sub1()
    On Error Resume Next
    ...
    On Error GoTo 0
    sub2
End Sub
Sub sub2()
    Dim i As Integer
    i = "x"
End Sub


Skip,
Skip@TheOfficeExperts.com
 
nah that thing that on error goto 0 is making my program do is going to the "End Sub" line from the sub that had the line on error goto next, which means that any run time error is not being picked up becuase whenever i say on error goto next, it just means simply that, ignore any runtime errors and execute the next line, i want to do the opposite of that where i tell it dont do that anymore, it seems to me that im going to have to just not have the first sub call the second one, becuase i dont see any other solution
 
On error goto 0 turns off on error resume next.

Isn't that what you want just before you call your subroutine in order that the called sub does NOT inherit resume next?

That's exactly what you asked for!

Skip,
Skip@TheOfficeExperts.com
 
No seriously, thats what I thought too, but for me, it does inherit that, i dont know why, maybe its the way i have my sub's set up but it really does, i tried using that goto 0 statement many different ways and it hasn't worked, but i'll just do what i said in my last past to solve the problem
 
wow i dont know what the heck was happening yesterday but now that goto 0 statement works, so thanks again!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top