How to Generate a list of Access Error Messages.

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

Hi;

Thought this post might be helpful.

Searched for more than an hour for a:
List of err.number descriptions.
err.number list.
err.number descripion
error number list.
And a lot of other combinations.

During the searches discovered that a lot of other people were looking for
the same thing.

Finally found the answer at:
http://support.microsoft.com/kb/268721/en-us
How to Generate a list of Access Error Messages.
It is for A2K but is probably useful for other versions.

Hope this helps someone.

Andy
 
Hi Andy,

The method shown in KB 268721 is based on ADO code. The table includes 32768
records, many of which are questionable at best (ie. "No Error" and
"Application-defined or object-defined error", which doesn't really tell one
a whole lot).

I prefer using a DAO code based method myself. I think the method shown
below came from another KB article, but I apparently did not document the
article number. To use this method, make sure that you have a reference set
to the "Microsoft DAO 3.6 Object Library".


Option Compare Database
Option Explicit

' How to Generate a list of Access Error Messages

Function AccessAndJetErrorsTable() As Boolean
Dim dbs As DAO.Database, tdf As DAO.TableDef, fld As DAO.Field
Dim rst As DAO.Recordset, lngCode As Long
Dim strAccessErr As String
Const conAppObjectError = "Application-defined or object-defined error"

On Error GoTo Error_AccessAndJetErrorsTable

Set dbs = CurrentDb
Set tdf = dbs.CreateTableDef("tblAccessAndJetErrors")

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("tblAccessAndJetErrors")
' Loop through error codes.
For lngCode = 0 To 32767
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 "tblAccessAndJetErrors table created."

AccessAndJetErrorsTable = True

Exit_AccessAndJetErrorsTable:
Exit Function

Error_AccessAndJetErrorsTable:
MsgBox Err & ": " & Err.Description
AccessAndJetErrorsTable = False
Resume Exit_AccessAndJetErrorsTable
End Function



Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
Back
Top