Error Codes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there anywhere thta has a list of the Access Error codes (or at least most of them) that occur in forms.

Ie what is Error 0

D
 
Most of the error numbers are between 0 and 4500. There's a built-in
function AccessError that will translate any error number to its message.

The follow code, copied from the Access 97 Help file, should help:

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

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


DMc2004 said:
Is there anywhere thta has a list of the Access Error codes (or at least
most of them) that occur in forms.
 
If using Access 2000 or newer you'll need to set a Reference to DAO to use
the function. In the code window go to Tools|Referneces and check the box
next to "Microsoft DAO 3.6 Object Library". Also, change the Dim statements
to:

Dim dbs As DAO.Database, tdf As DAO.TableDef, fld As DAO.Field
Dim rst As DAO.Recordset, lngCode As Long

--
Wayne Morgan
MS Access MVP


DMc2004 said:
Is there anywhere thta has a list of the Access Error codes (or at least
most of them) that occur in forms.
 
And specifically error 0 is no error at all.

If I see an error message with this, it usually means that I've dropped into my
error handling code because I forgot to put an Exit Function or Exit Sub just
before the error code begins.

Douglas J. Steele said:
Most of the error numbers are between 0 and 4500. There's a built-in
function AccessError that will translate any error number to its message.

S N I P
 
You are, of course, correct John. That's what I get for blythely copying
stuff from the Help file!
 
Back
Top