The information in this article applies to:
SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.
CAUSEThe 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. RESOLUTIONMake 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. STATUSThis 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.
Steps to Reproduce BehaviorCAUTION: 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.
Adding Logic to the Event ProcedureTo avoid generating an error message if there are no records, follow these steps:
Keywords : kberrmsg kbusage FmsEvnt |
Last Reviewed: April 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |