Microsoft KB Archive/105666: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - ">" to ">")
 
Line 65: Line 65:
       For i = 1 To 32766
       For i = 1 To 32766
         E$ = Error$(i)
         E$ = Error$(i)
         If E$ <&gt; "User-defined error" And E$ <&gt; "Reserved Error" Then
         If E$ <> "User-defined error" And E$ <> "Reserved Error" Then
             Debug.Print i; Error$(i)
             Debug.Print i; Error$(i)
         End If
         End If
Line 98: Line 98:
         For i = 1 To 32766
         For i = 1 To 32766
             e$ = Error$(i)
             e$ = Error$(i)
             If e$ <&gt; "User-defined Error" And e$ <&gt; "Reserved Error" Then
             If e$ <> "User-defined Error" And e$ <> "Reserved Error" Then
               MyTable.AddNew
               MyTable.AddNew
               MyTable![Err] = i
               MyTable![Err] = i

Latest revision as of 17:45, 20 July 2020

Knowledge Base


Article ID: 105666

Article Last Modified on 5/6/2003



APPLIES TO

  • Microsoft Access 1.0 Standard Edition
  • Microsoft Access 1.1 Standard Edition
  • Microsoft Access 2.0 Standard Edition



This article was previously published under Q105666

Moderate: Requires basic macro, coding, and interoperability skills.

SUMMARY

The Microsoft Access manuals do not contain a listing of all the error codes and messages you can receive when you are running custom Access Basic functions. To obtain the error codes and messages, you can run a custom Access Basic function and use the Microsoft Access Help system.

MORE INFORMATION

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x, or the "Building Applications" manual, Chapter 3, "Introducing Access Basic" in version 2.0.

There are approximately 700 error messages that can result from running Access Basic code. To print a list of the error values and descriptions to the 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 a table:

  1. 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
                            
  2. 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
                            
  3. Type the following line in the Immediate window, and then press ENTER:

     ? FillErrorTable()

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 the error value, match the description to the values returned by the FillErrorTable() function.

REFERENCES

For more information about error messages, search for "error messages: reference," and then "Error Messages Reference" using the Microsoft Access Help menu.


Additional query words: error messages

Keywords: kbhowto kbprogramming KB105666