This article was previously published under Q105666
This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.
The Microsoft Access manuals do not contain a listing of all the errorcodes and messages you can receive when you are running custom Access Basicfunctions. To obtain the error codes and messages, you can run a customAccess Basic function and use the Microsoft Access Help system.
This article assumes that you are familiar with Access Basic and withcreating Microsoft Access applications using the programming tools providedwith Microsoft Access. For more information on Access Basic, please referto the "Introduction to Programming" manual in Microsoft Access version1.x, or the "Building Applications" manual, Chapter 3, "Introducing AccessBasic" in version 2.0.
There are approximately 700 error messages that can result from runningAccess Basic code. To print a list of the error values and descriptions tothe Immediate window, add the sample function below to a module:
Function PrintErrorStrings () For i = 1 To 32766 E$ = Error$(i) If E$ <> "User-defined error" And E$ <> "Reserved Error" Then Debug.Print i; Error$(i) End If Next i End Function
The following example demonstrates how to save the error code list in atable:
Create a new table with the following fields. Save the table as Error Codes:
Table Name: Error Table ----------------------- Field Name: Err Data Type: Number Field Size: Integer Field Name: Error Data Type: Text Field Size: 255
Create the following function in a new module.
Function FillErrorTable() Dim MyDB As Database, MyTable As Recordset Dim i As Integer Dim e$ Set MyDB = CurrentDb() Set MyTable = MyDB.OpenRecordset("Error Codes") For i = 1 To 32766 e$ = Error$(i) If e$ <> "User-defined Error" And e$ <> "Reserved Error" Then MyTable.AddNew MyTable![Err] = i MyTable![Error] = e$ MyTable.UPDATE End If Next i MyTable.Close MyDB.Close End Function
Type the following line in the Immediate window, and then press ENTER:
The error codes and descriptions will be written to the Error Codes table.
The Microsoft Access Help system contains descriptions of the errors.However, the error values are not in the Help system. To determine theerror value, match the description to the values returned by theFillErrorTable() function.
For more information about error messages, search for "error messages:reference," and then "Error Messages Reference" using the Microsoft AccessHelp menu.