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 "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
- Save the module as Module1.
- Type the following line in the Immediate window, and then press ENTER: