Microsoft KB Archive/268721

= ACC2000: How to Generate a list of Access Error Messages =

Article ID: 268721

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q268721



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



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.



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.

 Create a new Access database (.mdb). 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

 Save the table as tblErrorsAndDescriptions . Close the table. Create a new module.  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 &quot;tblErrorsAndDescriptions&quot;, ADOcnn, adOpenDynamic, adLockOptimistic

With ADOrst For intCounter = 0 To 32767 .AddNew !ErrorNumber = intCounter If IsNull(AccessError(intCounter)) Then !ErrorDescription = &quot;No Error&quot; ElseIf AccessError(intCounter) = &quot;&quot; Then !ErrorDescription = &quot;No Error&quot; Else !ErrorDescription = AccessError(intCounter) End If       .Update Next intCounter End With

MsgBox &quot;Completed enumerating errors to the table.&quot;

End Function

</li> Save the module as Module1 .</li>  Type the following line in the Immediate window, and then press ENTER: sRecordAccessErrorMsg </li></ol>

Additional query words: display show make all errors

Keywords: kbhowto KB268721

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.