Error handling between multiple functions

buratti

Registered User.
Local time
Today, 17:04
Joined
Jul 8, 2009
Messages
234
I have a function (lets call it Function1) that runs several calulations and etc. One of the first lines of this function is the error handling line of:
On Error goto err
Then in the err section I have the appropiate error trapping code.

Somewhere in the middle of Function1 I call Function2, which runs additional calculations, and when finished resumes where left off on Function1. In Function2 I have similar error trapping like in Function1 (on Error Goto errr)

The problem I am having is that if an error occurs in Function2, it returns to the err section within Function1, not within Function2 from where the error occured. How do I keep the error traping that occurs in Function2 in Function2?
 
i don't think you are right

the error trap in function 2 should work correctly.

Can you post your code in F2
 
i don't think you are right

the error trap in function 2 should work correctly.

Can you post your code in F2

Sorry for the delay, have a new problem I am working on which I just posted a new question for that. My new problem is preventing me from accessing my VBA code, so this is off the top of my head here...

From my memory I think I was inncorect. Function2 does not actually have an error trap, but rather I used On Error goto 0 in the first line. I remember that I used this because I was still technically debugging function2 and I wanted to have access break on the error, rather than trap it inside function1, so I can determine what to actually do with the error. But even with using goto 0, it still goes to function1's err section.

Now, I am unable to test it because the problem I stated above, but in theory I think I may have solved it. Technically speaking, if I set on error goto 0 inside function1 in the line before calling function2 then set it back to goto err in the line after calling it, it "should" work, but then again like you stated, it "should" be working the way I already have it. Your thoughts on my idea?
 

Users who are viewing this thread

Back
Top Bottom