ACC: Error() Function Does Not Return Detailed Information (89591)



The information in this article applies to:

  • Microsoft Access 1.0
  • Microsoft Access 1.1
  • Microsoft Access 2.0

This article was previously published under Q89591
Moderate: Requires basic macro, coding, and interoperability skills.

SUMMARY

When you use the Error(Err) function to trap errors in Access Basic, you will receive a limited error message. To receive an extended error message, use the Error() or Error$() functions. For example, Error(Err) or Error$(Err) might return the message "Table not found" whereas Error() or Error$() would return the message "Table MyTable not found."

MORE INFORMATION

The following is an example of a common format for error handling in Access Basic using MsgBox to display the error text:
MsgBox "Error #" & Err & ": " & Error(Err)

This line would return an error message like "Error #15: File | Not found" if Err had trapped a "file not found" error.

To receive the extended error message use:
MsgBox "Error #" & Err & ": " & Error

Note the use of Error and not Error(Err).

Error(Err) returns a generic error message for the given error number whereas Error returns a specific error message.

NOTE: This behavior does not occur in Microsoft Access version 7.0.

Modification Type:MajorLast Reviewed:5/9/2003
Keywords:kbinfo kbProgramming KB89591