Trap Errors in Module

D

Dave Elliott

I am not good at all in modules, but I need to trap any and all errors via a
module if possible!
I succeeded in creating a mde, but it does show some errors when I close the
db even though it compiles fine.
Tried this mod named ModErrors with no success.
Any Suggestions?

Option Explicit
Dim result
On Error GoTo Database_Err
Database_Err:
MsgBox "Error " & err & ": " & Error$
If err <> 0 Then Resume
Exit Function
End Sub
 
A

Allen Browne

The error handling needs to go into *each* sub and every function in all
modules. You cannot just place it at the top of the module like that.

In each procedure, you can call a generic function that handles the errors.
That makes it really easy to manage, and the function can perform tasks such
as logging the errors for your. Example at:
Error Handling in VBA
at:
http://members.iinet.net.au/~allenbrowne/ser-23a.html

BTW, you also need to use the Error event of each form to catch the
engine-level errors such as "duplicate index", "invalid type", ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top