Heenan, Lambert
Lambert.Heenan at AIG.com
Tue Jul 27 11:12:33 CDT 2004
This code will create tables for you containing the error codes and descriptions... Option Compare Database Option Explicit Sub CreateErrorsTable() Dim dbs As Database, tdf As TableDef, fld As Field Dim rst As Recordset, lngCode As Long Const conAppObjectError = "Application-defined or object-defined error" ' Create Errors table with ErrorNumber and ErrorDescription fields. Set dbs = CurrentDb Set tdf = dbs.CreateTableDef("Errors") Set fld = tdf.CreateField("ErrorCode", dbLong) tdf.Fields.Append fld Set fld = tdf.CreateField("ErrorString", dbText, 255) tdf.Fields.Append fld dbs.TableDefs.Append tdf ' Open recordset on Errors table. Set rst = dbs.OpenRecordset("Errors") ' Loop through first 1000 Visual Basic error codes. For lngCode = 1 To 1000 On Error Resume Next ' Raise each error. Err.Raise lngCode DoCmd.Hourglass True ' Skip error codes that generate application or object-defined errors. If Err.Description <> conAppObjectError Then ' Add each error code and string to Errors table. rst.AddNew rst!ErrorCode = Err.Number rst!ErrorString = Err.Description rst.Update End If ' Clear Err object. Err.Clear Next lngCode ' Close recordset. rst.Close DoCmd.Hourglass False MsgBox "Errors table created." End Sub Function AccessAndJetErrorsTable() As Boolean Dim dbs As Database, tdf As TableDef, fld As Field Dim rst As Recordset, lngCode As Long Dim strAccessErr As String Const conAppObjectError = "Application-defined or object-defined error" On Error GoTo Error_AccessAndJetErrorsTable ' Create Errors table with ErrorNumber and ErrorDescription fields. Set dbs = CurrentDb Set tdf = dbs.CreateTableDef("AccessAndJetErrors") Set fld = tdf.CreateField("ErrorCode", dbLong) tdf.Fields.Append fld Set fld = tdf.CreateField("ErrorString", dbMemo) tdf.Fields.Append fld dbs.TableDefs.Append tdf ' Open recordset on Errors table. Set rst = dbs.OpenRecordset("AccessAndJetErrors") ' Loop through error codes. For lngCode = 0 To 3500 On Error Resume Next ' Raise each error. strAccessErr = AccessError(lngCode) DoCmd.Hourglass True ' Skip error numbers without associated strings. If strAccessErr <> "" Then ' Skip codes that generate application or object-defined errors. If strAccessErr <> conAppObjectError Then ' Add each error code and string to Errors table. rst.AddNew rst!ErrorCode = lngCode ' Append string to memo field. rst!ErrorString.AppendChunk strAccessErr rst.Update End If End If Next lngCode ' Close recordset. rst.Close DoCmd.Hourglass False RefreshDatabaseWindow MsgBox "Access and Jet errors table created." AccessAndJetErrorsTable = True Exit_AccessAndJetErrorsTable: Exit Function Error_AccessAndJetErrorsTable: MsgBox Err & ": " & Err.Description AccessAndJetErrorsTable = False Resume Exit_AccessAndJetErrorsTable End Function HTH Lambert -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin - Beach Access Software Sent: Tuesday, July 27, 2004 12:04 PM To: AccessD at databaseadvisors.com Subject: [AccessD] Error List Does anyone have a link to a list of VBA error? MTIA Rocky Smolin Beach Access Software http://www.e-z-mrp.com -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com