Error 2046



I ran the following code to get the errors table:

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 3000
On Error Resume Next
' Raise each error.
Err.Raise lngCode
DoCmd.Hourglass True
' Skip error codes that generate application or object-defined
If Err.Description <> conAppObjectError Then
' Add each error code and string to Errors table.

rst!ErrorCode = Err.Number
rst!ErrorString = Err.Description
End If
' Clear Err object.
Next lngCode
' Close recordset.
DoCmd.Hourglass False
MsgBox "Errors table created."
End Sub

When I run this code 2046 comes up "Application-defined or object-defined
error" which is confusing since
after doing an internet search, this is a known access error. I am confused
on how access does error handling.

'69 Camaro

Hi, Tom.
When I run this code 2046 comes up "Application-defined or object-defined

For code that works, please see the tip, "How to create a listing of the
Access and Jet errors," on the following Web page:


See for all your database needs.
See for Microsoft Access tips and tutorials.
Blog: for contact

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question