The information in this article applies to:
SYMPTOMS
If a data control and text box are both bound to an empty table in a
database, clicking the data control arrows gives this error:
This error also occurs if you enter text into the text box, and execute the AddNew method or the Edit method while the database table is empty. The program has difficulty recovering because of the recurring "No Current Record" errors. The On Error statement fails to trap this error. CAUSE
The program does not know the table is empty until the automatic record
update occurs. That automatic record update occurs when you click the data
control arrow or you enter text in the text box and then execute an AddNew
or Edit method.
WORKAROUNDTo work around this behavior, execute the AddNew method on an empty database table before allowing the user to click the data control or enter text into the bound text box control. For example, set the Enabled property for the text control and data control to False at the beginning of the program. Then you can force the user to click a command button that executes the AddNew method before enabling the text and data controls. STATUS
This behavior is by design. This design is under review and will be
considered for enhancement in a future release.
More InformationHow to Create an Empty Microsoft Access DatabaseBefore using Example 1 or 2 shown below, create an empty database by following these steps in Visual Basic:
Example One: Steps to Reproduce Behavior using a Data Control
Example One WorkaroundTo work around this behavior, set the Enabled property for the text and data controls to False at design time or in the Load procedure for the form. Then add the following to the top of the Command1_Click procedure before the AddNew:
This prevents the user from automatically updating an empty database, thus avoiding the no current record error. Example Two: Steps to Reproduce Behavior Using Object Variables
REFERENCES
Additional information can be found in the Visual Basic Help menu. The no
current record error is described in the Visual Basic Help topic "Data
Access error messages." Here is that description:
This error occurs following the unsuccessful application of one of the FindFirst, FindLast, FindNext, FindPrevious Methods or the Seek Method, or when the underlying recordset contains no records. Move to or select a record, and then try the operation again. The following is paraphrased from the Help topic for AddNew in Visual Basic: The AddNew method clears the copy buffer in preparation for creating a new record in a Table or Dynaset. AddNew sets all fields in the copy buffer to Null and makes it the current record. After putting data in the record, you can use the Update method to add the record to the recordset. Update is automatically invoked with a data control if an Edit or AddNew operation is pending when you use one of the Find or Move methods. Additional query words: 3.00
Keywords : |
Last Reviewed: June 14, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |