Isaac
Lifelong Learner
- Local time
- Today, 13:43
- Joined
- Mar 14, 2017
- Messages
- 11,767
If I understand you correctly, all you would have to do is trap for that particular err.Number and simply do nothing and resume where you left off...?
I cannot tell for sure - you may not be understanding (or maybe it's me who doesn't understand what you're suggesting).
Remember, we're already in the error handler, because of some (probably) different error.
So I may have created my code and made some dumb mistake. I get something like "object not set" or whatever.
At that time, my error handler is hit. Inside it, I want to just 'clean up' some other (unrelated to the error) things.
Particularly, I want to kill the log file if it exists. But, I'd like to effective ignore any additional error that occurs while trying to delete it, just give up deleting it at that point.
I think what you're suggesting might be something like this:
Code:
Function Foo()
On Error GoTo Errhandler
........code runs, does whatever
ExitFunction:
Exit Function
Errhandler:
if blLogExists then
On Error Resume Next
Now try to kill log file
If err.number=9 then 'permission denied
Resume ExitFunction
End if
End Function
The problem is that structure would suffer from the same malady as the first one - the On Error Resume Next (which is what you'd use to allow an error to occur but not hard stop, then check for Err.Number) is totally ignored in the first place.
In both cases, the code never gets past the line that tries to delete the log file.
If I've misunderstood, please post a suggested code structure.