ACC2: "Reserved Error" Message with No Error Code

Last reviewed: May 7, 1997
Article ID: Q126825
The information in this article applies to:
  • Microsoft Access version 2.0

SYMPTOMS

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

When you use the SetFocus method in an event procedure, you receive the error message "Reserved Error" without any other error code or explanation.

CAUSE

The form containing the event procedure is based on a table or query with no records, and the form is either read-only or its DefaultEditing property is set to Read Only or Can't Add Records. The SetFocus method must identify the current record before it can move the focus to another control. If there are no records and you cannot create a new record, then there is no current record. An attempt to identify the current record results in an error.

RESOLUTION

Make sure that the table or query on which the form is based contains at least one record, or include logic in your event procedure to avoid using the SetFocus method if there are no records.

STATUS

This behavior no longer occurs in Microsoft Access version 7.0.

MORE INFORMATION

The GoToControl action also causes an error under the same circumstances, but it issues a more informative error (2105, "Can't go to specified record"). Both the GoToControl action and the SetFocus method attempt to identify the current record. If the form is based on a table or query with no records, there is no current record and an error occurs.

Note that when a form is based on a table or query with no records, none of the controls in the form's detail section appear, including unbound controls. Unbound controls in a header or footer section do appear. This error occurs even when you try to set the focus to an unbound control that is visible in the form header or footer.

Steps to Reproduce Behavior

CAUTION: Following the steps in this example will modify the sample database NWIND.MDB. You may want to back up the NWIND.MDB file, or perform these steps on a copy of the NWIND database.

  1. Open the sample database NWIND.MDB.

  2. Create the following query based on the Employees table:

          Query: ReservedErrorsQuery
          --------------------------
          Type: Select Query
          Field: *
    
             Table: Employees
          Field: Employee ID
             Criteria: < 0
    
       This query should return no records.
    
    

  3. Modify the Employees form as follows:

    a. Change the form's RecordSource property to ReservedErrorQuery.

    b. Change the form's DefaultEditing property to Can't Add Records.

  4. Add an unbound control named MyUnboundCtl to the form header.

  5. Add the following code to the form's OnOpen event procedure:

          Me!MyUnboundCtl.SetFocus
    

  6. View the form in Form view. Note the error message.

  7. Change the code in the OnOpen event procedure to:

          DoCmd GoToControl Me!MyUnboundCtl.Name
    

  8. View the form in Form view. Note the more informative error message.

Adding Logic to the Event Procedure

To avoid generating an error message if there are no records, follow these steps:

  1. Open the modified Employees form in Design view. Change the code in the Open event procedure as follows:

          If Me.RecordsetClone.RecordCount > 0 Then
    
             Me!MyUnboundCtl.SetFocus
          End If
    
    

  2. View the form in Form view. Note that no error message is generated.


Keywords : FmsEvnt kberrmsg kbusage
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.