By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,775 Members | 2,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,775 IT Pros & Developers. It's quick & easy.

ErrorTable/Log

P: n/a
DD
I have started adding error traping code to my forms! should i make a
errortbl and log?
If so can i do this in a module as a function?
also i am not sure if i understand the process TO link the table with
the module/
Any help please
DD
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
This really requires a fully fledged explanation of DAO/ADO and how the
Access Data Layer interacts with the rest of the application, but as I have
to work for a living I'll skip it.

Create a table (e.g. tbErrorLog) with the following fields:

ErrorLogID Autonumber
ErrorLogNumber Number (preferably of the Long variety)
ErrorLogDescription Text (255)
ErrorLogLocation Text (255)

Create a query with the following SQL (to do this create a new query, go to
View/SQL View, then paste the SQL in) and call it appParmsErrorLog

PARAMETERS lngErr Long, txtDesc Text(255), txtLocation Text(255);
INSERT INTO tbErrorLog (ErrorLogNumber,ErrorLogDescription,ErrorLogLocati on)
VALUES (lngErr,txtDesc,txtLocation);

Create a module (e.g. modErrorLog) with the following function:

Public Function ErrorLog(ByVal plngError as Long, ByVal pstrLocation as
String) as Boolean

Dim qdfError as DAO.QueryDef

Set qdfError = CurrentDB.QueryDefs("appParmsErrorLog")

qdfError.Parameters("lngErr").Value = plngError
qdfError.Parameters("txtDesc").Value = Error(plngError)
qdfError.Parameters("txtLocation").Value = IIf(pstrLocation =
"",Null,pstrLocation)

qdfError.Execute

ErrorLog=True

Exit Function

ErrorLog_Err:
ErrorLog=False

End Function

Make sure you set a reference to the Microsoft DAO Library (as high a
version as you've got) and then amend your error handling code to something
like so:

Public Sub DoSomething

On Error Goto DoSomething_Err

'...misc code

Exit Sub

DoSomething_Err:
If Not ErrorLog(err,"frmSomething|DoSomething") Then
Msgbox "There was an error in the error recording
procedure",vbCritical,"Error"
Else
Msgbox "An error occurred and has been written to the error
log",vbInformation,"Error"
End If

End Sub

If you're feeling particularly adventurous you could modify it to include a
form which collects information from the user about what they were doing
when the error occurred. The basics should be there to get you started
though.

hth

~Ben
"DD" <da**********@bigpond.com.au> wrote in message
news:14*************************@posting.google.co m...
I have started adding error traping code to my forms! should i make a
errortbl and log?
If so can i do this in a module as a function?
also i am not sure if i understand the process TO link the table with
the module/
Any help please
DD

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.