vb123.com.au
Function ErrorLog(strErrDesc As String, lngErrNum As Long, strWhereFrom As String) As Boolean On Error GoTo Err_ErrorLog Dim strMsg As String ErrorLog = True strMsg = strMsg & "There has been an error in the application." & vbCrLf & vbCrLf strMsg = strMsg & "Error Number: " & lngErrNum & vbCrLf strMsg = strMsg & "Error Description: " & strErrDesc & vbCrLf strMsg = strMsg & "Error Location: " & strWhereFrom & vbCrLf strMsg = strMsg & "Please note the above information when contacting Support." & vbCrLf & vbCrLf strMsg = strMsg & "support@developersforhire.co.uk" MsgBox strMsg, vbInformation, "Error Log." Exit_ErrorLog: Exit Function Err_ErrorLog: ErrorLog = False MsgBox Err.Description, vbExcalmation, "Error detected." Resume Exit_ErrorLog End Function
Err_SomeRoutine: Call ErrorLog(Err.Description, Err.Number, Me.Name)NOT
Err_SomeRoutine: MsgBox Err.Description, Err.Number, "Error"
The last argument is where the error code is sitting. In the above example we
are passing the name of the form we are currently executing the code from.
You could improve the functionality of the above function by introducing logging
to a database table. We have included this functionality within the download
Rob Henderson
Developer from Aberdeen in Scotland
Sample database is suited to all versions of Access
If you do NOT own "The Toolbox", Click
here to find out how to purchase The Toolbox.
Track all changes made
to a record in Microsoft Access
Access 2002 (XP)
Trappable Errors Numbers And Descriptions
Replace Your File API’s With
The FileDialog Object
Click on the following button
to jump to the next page in the document loop.
Get Good Help Here
If you need help with a database or Office programming, our
Professionals could be the answer because we have worked on many similar
solutions
Frontpage Conversions
We have converted vb123.com to
Expression Web, contact us if we can help you move to the latest
Microsoft web tool.
About The Editor ~ Contact Us
Garry Robinson writes for a number
of popular computer magazines, is now a book author and has worked on
100+ Access databases. He is based in Sydney, Australia
"For a completely innovative way of achieving what Rob talks about in
this article (and much more) consider using Wayne's SimplyVBA Global
Error Handler.
Wayne's tool gives you a way of achieving this without having to alter
every single subroutine to implement the global function which in turn
reduces code size considerably. Free developer edition for non
commercial use is also available."
Read More here