Microsoft Access Error Numbering

T

Tom Allen

Is there a place where I can see how Error numbers are
defined ?
EXAMPLE:
Wrong data type entered in a control on a form:

Const conWrongValue = 2113

- How do I know it's 2113?
- How is that number determined?
- Where can I see a list of all error numbers?
 
6

'69 Camaro

Hi, Tom.
Is there a place where I can see how Error numbers are
defined ?

You can create your own table listing all of the error numbers and the error
descriptions. Pasted here from the Access 97 Help topic (with
disambiguation for the DAO library for later versions of Access, but you'll
still need to set a Reference to DAO 3.6 to use this function in Access 2K
and later):

The following procedure creates a table containing many of the error codes
and strings used or reserved by Microsoft Access and by the Microsoft Jet
database engine. Not all error codes are included in the resulting table, as
some exist outside the range of error codes evaluated by this procedure (0
to 4500).



Function AccessAndJetErrorsTable() As Boolean

Dim dbs As Database, tdf As 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

' 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



' **** End code section ****

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
Top