ACC2000: Using the AddNew Method with RecordsetClone Moves Form to New Record (241025)
The information in this article applies to:
This article was previously published under Q241025 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access database (.mdb).
SYMPTOMS
When you use the AddNew method on a recordset object variable created from the RecordsetClone property of a form, the form incorrectly moves to a new record.
RESOLUTION
To resolve this problem, obtain Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a).
To obtain SR-1/SR-1a, click the article number below to view the article in the Microsoft Knowledge Base:
245025 OFF2000: How to Obtain and Install Microsoft Office 2000 Service Release 1/1a (SR-1/SR-1a)
To temporarily work around this problem, use the Clone method to create a copy of the Recordset property of the form, and then manipulate the copy of the recordset. To use the Clone method with the Recordset property of the form, follow these steps. 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. - Open the sample database Northwind.mdb.
- Open the Customers form in Design view.
- Add a command button to the form with the following properties:
Command button
---------------------------
Name: Command1
Caption: AddNew
OnClick: [Event Procedure]
- Set the OnClick property of the command button to the following event procedure:
Private Sub Command1_Click()
Dim rs As DAO.Recordset
Set rs = Me.Recordset.Clone
rs.AddNew
rs!CustomerID = "AAAAA"
rs!CompanyName = "AAAAA Company"
rs.Update
End Sub
- Save the form and close it.
- Open the Customers form in Form view.
- Click the command button.
Note that the record is added to the clone of the recordset of the form without affecting the form's current position. To actually see the record, you must requery the form, or close and reopen it.
STATUSMicrosoft has confirmed that this is a problem in Microsoft Access 2000.
This problem was corrected in Microsoft Office 2000 SR-1/SR-1a.
Modification Type: | Major | Last Reviewed: | 11/25/2002 |
---|
Keywords: | kbbug KB241025 |
---|
|