Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Generate a list of Access Error Messages


View products that this article applies to.

Summary

This article shows you how to programmatically create a list of Access error messages and to save the results to an Access table, complete with the associated error number.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
  1. Create a new Access database (.mdb).
  2. Create the following table:
    Table: tblErrorsAndDescriptions
    -------------------------------

    Field Name: ErrorNumber
    Data Type: Number
    Indexed: Yes (No Duplicates)
    Primary Key: Yes

    Field Name: ErrorDescription
    Data Type: Memo
  3. Save the table as tblErrorsAndDescriptions.
  4. Close the table.
  5. Create a new module.
  6. Type or paste the following code into the module:
    Option Compare Database
    
    Function sRecordAccessErrorMsg()
    
    Dim ADOcnn As ADODB.Connection
    Dim ADOrst As ADODB.Recordset
    
    Dim intCounter As Long
    Dim intErrornumber As Long
    Dim strErrorText As String
    
    Set ADOcnn = CurrentProject.Connection
    Set ADOrst = New ADODB.Recordset
    
    ADOrst.Open "tblErrorsAndDescriptions", ADOcnn, adOpenDynamic, adLockOptimistic
    
    With ADOrst
        For intCounter = 0 To 32767
            .AddNew
            !ErrorNumber = intCounter
            If IsNull(AccessError(intCounter)) Then
                !ErrorDescription = "No Error"
            ElseIf AccessError(intCounter) = "" Then
                !ErrorDescription = "No Error"
            Else
                !ErrorDescription = AccessError(intCounter)
            End If
            .Update
        Next intCounter
    End With
    
    MsgBox "Completed enumerating errors to the table."
    
    End Function
    
    					
  7. Save the module as Module1.
  8. Type the following line in the Immediate window, and then press ENTER:
    sRecordAccessErrorMsg
    					

↑ Back to the top


Keywords: KB268721, kbhowto

↑ Back to the top

Article Info
Article ID : 268721
Revision : 3
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 298