ACC2000: "Application-defined or object-defined error" Error
This article was previously published under Q208704
This article has been archived. It is offered "as is" and will no longer be updated.
Advanced: Requires expert coding, interoperability, and multiuser skills.
If you use the Error() or Error$() functions to get the textual descriptionof an error message, you may receive the following error message:
Application-defined or object-defined errorYou may receive this error message when you try to get the description ofan error trapped in a form's Error event as follows:
Private Sub Form_Error(DataErr As Integer, Response As Integer) MsgBox Error(DataErr) Response = acDataErrContinueEnd Sub
The error message being trapped is Microsoft Access specific. When you passan error number to the Error() function that is not a Visual Basic forApplications specific error, Visual Basic for Applications does not callback into the hosting application to ask it for the error message.
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. You can use the AccessError method to return the descriptive string associated with an Access error as follows:
NOTE: The AccessError method will return a string associated only with Access errors and Visual Basic errors. It will not return descriptive strings associated with data access errors.
Private Sub Form_Error(DataErr As Integer, Response As Integer) MsgBox Application.AccessError(DataErr) Response = acDataErrContinueEnd Sub
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.
Steps to Reproduce Behavior
- Open the sample database Northwind.mdb.
- Open the Orders table in Design view.
- Set the Required property of the EmployeeID field to Yes, and then close the table.
- Click Yes to the following prompt:Data integrity rules have been changed. Existing data may not be valid for the new rules.
This process may take a long time. Do you want the existing data to be tested with the new rules?
- Open the Orders form in Design view and set the following form property:OnError: [Event Procedure]
- Type the following code in the form module:
Private Sub Form_Error(DataErr As Integer, Response As Integer) MsgBox Error$(DataErr) MsgBox Application.AccessError(DataErr) Response = acDataErrDisplayEnd Sub
- View the form in Form view and click the New Record toolbar button to advance to a new Order record.
- Type the following line in Bill To: and press ENTER:Hello World!Note that you receive the following three messages:Application-defined or object-defined error.The text you entered isn't an item in the list.The text you entered isn't an item in the list.
NOTE: Because the Response variable is set to acDataErrDisplay, the error is not trapped. The third message above is the actual error message.
- Click to select a customer in the Bill To: list.
- Click Save Record on the Records menu. Note that you receive the following three messages:Application-defined or object-defined error< a message box with no text appears >Field 'Orders.EmployeeID' can't contain a null value.NOTE: The second message box is empty because the error generated is a data access error. The AccessError method does not return data access error messages.
For more information about the AccessError method, in the VisualBasic Editor, click Microsoft Visual Basic Help on theHelp menu, type "AccessError" in the Office Assistant orthe Answer Wizard, and then click Search to view the topic.
pra the text you entered isn t an item in the list
Article ID: 208704 - Last Review: 12/05/2015 10:55:16 - Revision: 3.2
Microsoft Access 2000 Standard Edition
- kbnosurvey kbarchive kberrmsg kbprb kbprogramming KB208704