I actually try do this same thing in every program I write -- it makes debugging a snap.
Every module and function I write has a header and footer, like:
Private Const ModuleName = "MyModule"
Public Function MyFunction()
Const ProcName = "MyFunction"
On Error Goto ErrorHandle
'--------PROCEDURE CODE------------------
'--------ERROR HANDLERS------------------
ErrorHandle:
Dim ErrSource as String
ErrSource = Err.Source
'Filter out the App Name, so it won't be at the
'end of the string
If (ErrSource = App.Name) Then
ErrSource = ModuleName & "." & ProcName
Else
ErrSource = ModuleName & "." & "!" & ErrSource
End If
Err.Raise ErrSource, Err.Source, Err.Description
End Function
Whenever an error is raised, the error source is defaulted to the application name. So, if the error source is the app name, I know this is the beginning of the error, and I set the source to be the current module and procedure.
Since each procedure re-raises the error up the call stack to it's calling procedure, each procedure adds its module and procedure name to the front of the source, so by the time you get to the top of the call stack, you have a string that looks like
Module1.Proc1!Module2.Proc2!Module3.Proc3
So you know exactly which procedures were running when this error occurred.
This method is high maintenance -- you have a lot of copying and pasting to do (unless you get an add-in to do it for you), but it is the only way I've found to get this functionality.
If somebody else has an easier way to do this, I'd love to see it! :-Q
Steve [sig][/sig]