Error Code Tables

siskoray

New member
Local time
Today, 16:00
Joined
May 5, 2001
Messages
7
As a somewhat new member of the VBA arena I am having problems producing the error list table that the Access Help offers to be able to identify error codes and their descriptions. I copy and paste, per the help, and continue to receive a "User Defined Type - Not Defined" message. I have pasted both the procedure example and the function example yet have had no luck.

Any help would be greatly appreciated. Especially if someone would be willing to email be the database with a successful created table with error codes.

Thanks.
 
I use the following to display error numbers and text although I did run the code to build the table so I could look at it.

MsgBox Err.Number & "-" & Err.Description

Here's the function that worked for me:
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
 
Thanks for answering my question. Actually I did use the exact same code but to no avail. I think I might be missing a step. This is what I did. I used the code that you demonstrated and pasted it into a new module. Then I ran it through the debug option and the error message returns.

Thanks.
 
Pat, I need to revise my last question. I was able to print out the table, but now I have another question on the same subject. One of my goals was to be able to customize an error message, but the one I'm looking for doesn't appear on the code list. Are there other codes?

The one I'm looking for stars with "Miscrosoft Access can't append all the records.... " Basically telling me that the append action query was not able to fully append and # records did not append due to null values, etc...."

Any help is greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom