Applies To Error object.
Description
Returns a descriptive string associated with an error.
Return Values The return value is a String data type that describes the error. Remarks The Description property comprises a short description of the error. Use this property to alert the user about an error that you cannot or do not want to handle.See Also AllowZeroLength property, Required property, TableDef object, ValidateOnSet property, ValidationRule property, ValidationText property, Value property.
Specifics (Microsoft Access) In Microsoft Access, if you set the DAO DefaultValue property to GenUniqueID( ) to create an AutoNumber field, you must also set the Attributes property to dbAutoIncrement. If you don't set the Attributes property in this way, Microsoft Access won't assign the AutoNumber data type to the field, and you'll get an error when you try to view the table in Datasheet view. The following code shows how you can create a field with the AutoNumber data type, given a TableDef object variable tdf and a Field object variable fld.Set fld = tdf.CreateField("EmployeeID", dbLong)
fld.DefaultValue = "GenUniqueID()"
fld.Attributes = dbAutoIncrField
tdf.Fields.Append fld
If the DAO DefaultValue property setting is an expression, it can't contain user-defined functions, Microsoft Access domain aggregate functions, SQL aggregate functions, the CurrentUser function, the Eval function, or references to queries, forms, or other Field objects.
Example
This example forces an error, traps it, and displays the Description, Number, Source, HelpContext, and HelpFile properties of the resulting Error object.
Sub DescriptionX()
Dim dbsTest As Database
On Error GoTo ErrorHandler
' Intentionally trigger an error.
Set dbsTest = OpenDatabase("NoDatabase")
Exit Sub
ErrorHandler:
Dim strError As String
Dim errLoop As Error
' Enumerate Errors collection and display properties of
' each Error object.
For Each errLoop In Errors
With errLoop
strError = _
"Error #" & .Number & vbCr
strError = strError & _
" " & .Description & vbCr
strError = strError & _
" (Source: " & .Source & ")" & vbCr
strError = strError & _
"Press F1 to see topic " & .HelpContext & vbCr
strError = strError & _
" in the file " & .HelpFile & "."
End With
MsgBox strError
Next
Resume Next
End Sub