G Guest Nov 9, 2004 #1 I would like to keep a log of errors received by the database users so I can determine any trends or anamolies.
I would like to keep a log of errors received by the database users so I can determine any trends or anamolies.
N Nick Coe \(UK\) Nov 9, 2004 #2 Store the error codes you trap in a table. I'm making this up as I go along so be a bit circumspect about trying to just paste it and use it. You create yourself a new table tblErrHist with columns something like: ErrCode(Long) ErrWhen(Date/Time) An autonumber PrimaryKey won't hurt either. Create a function to store the error so that you can just call it from each of your error traps. Public Function StowErr(lngErrCode as long) as boolean DoCmd.RunSQL "INSERT INTO tblErrHist ErrCode, ErrWhen " _ & "VALUES " & lngErrCode & ", " & Now() & ";" StowErr=True End Function **************** Where you error trap in your code: Dim bStowed as boolean On Error GoTo ErrRoutine ~blah blah your code ExitHere: 'Close rst's and nothingify as necessary Exit Func/Proc/Sub ErrRoutine: Select Case Err.Number Case ?? Case Else MsgBox Err.Description End Select bStowed = StowErr(Err.Number) GoTo ExitHere End Func/Proc/Sub That should do it, got a feeling I've forgotten something though...
Store the error codes you trap in a table. I'm making this up as I go along so be a bit circumspect about trying to just paste it and use it. You create yourself a new table tblErrHist with columns something like: ErrCode(Long) ErrWhen(Date/Time) An autonumber PrimaryKey won't hurt either. Create a function to store the error so that you can just call it from each of your error traps. Public Function StowErr(lngErrCode as long) as boolean DoCmd.RunSQL "INSERT INTO tblErrHist ErrCode, ErrWhen " _ & "VALUES " & lngErrCode & ", " & Now() & ";" StowErr=True End Function **************** Where you error trap in your code: Dim bStowed as boolean On Error GoTo ErrRoutine ~blah blah your code ExitHere: 'Close rst's and nothingify as necessary Exit Func/Proc/Sub ErrRoutine: Select Case Err.Number Case ?? Case Else MsgBox Err.Description End Select bStowed = StowErr(Err.Number) GoTo ExitHere End Func/Proc/Sub That should do it, got a feeling I've forgotten something though...
A Allen Browne Nov 9, 2004 #3 Good move. See: Error Handling in VBA at: http://members.iinet.net.au/~allenbrowne/ser-23a.html The article explains how to build a table to hold the error mesages, dates, user, etc, and a function to call in your error handlers.
Good move. See: Error Handling in VBA at: http://members.iinet.net.au/~allenbrowne/ser-23a.html The article explains how to build a table to hold the error mesages, dates, user, etc, and a function to call in your error handlers.