exception handling across methods in access

nisha

Registered User.
Local time
Today, 05:45
Joined
Aug 18, 2009
Messages
22
syntax to throw exception from a method.
i believe within a method i can handle errors like following:

private sub method1()
on error goto error1
call method2
statements1
statement2
error1:

end sub

private sub method2()

'' here i want to throw an exception so that it bounces back in method1 and statements after teh call are not executed.


end sub

guess few ppl might think of why not using a boolean value as return value from a method2 and based on that decide whether to execute later sttatements or not but due to some constraint i cannot do that.

Hmmmn... now the syntax plz.:confused:
 
I guess you could use a public variable to pass a value back to the first sub. Trying hard to understand why you could not use an error return value though.
 
Run the Raise method of the VBA.ErrObject object. Code looks like...
Code:
Err.Raise -4818237, "Source of error", "Error description"
 
Once you handle the error like Lagbolt suggests then just make sure you Exit the function or sub in the error handler instead of using Resume Next.
 

Users who are viewing this thread

Back
Top Bottom