Microsoft KB Archive/223224

= ACC2000: Setting Form Recordset Causes Dirty Record to Commit =

Article ID: 223224

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q223224



This article applies only to a Microsoft Access database (.mdb).

Advanced: Requires expert coding, interoperability, and multiuser skills.



SYMPTOMS
If you have two forms open with the same record source, and you programmatically set the recordset of one form to be equal to the recordset of the second form, any edits you have made thus far on the second form are committed to the data source.



RESOLUTION
If you have two forms based on the same data source, do not set one form's recordset equal to the other during data entry.



MORE INFORMATION
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.  Create a form called Cat1 with the following characteristics:   Form: Cat1 Caption: Cat1 RecordSource: Categories

Text Box -  Name: CategoryID ControlSource: CategoryID

Text Box --  Name: Description ControlSource: Description   Create a second form called Cat2 with the following characteristics:   Form: Cat2 -  Caption: TestForm RecordSource: Categories

Text Box -  Name: CategoryID ControlSource: CategoryID

Text Box --  Name: Description ControlSource: Description  Open both forms in Form view, each on the first record. In form Cat2, change the Description to the following text, and leave the pointer in the field. Do not press ENTER.

Beer, ales, teas, coffees, and soft drinks

</li> Press CTRL+G to open the Immediate window.</li>  Type the following in the Immediate window: Set Forms("Cat1").Recordset = Forms("Cat2").Recordset </li> After pressing ENTER in the Immediate window, note that Description on the form Cat1 now has the text that you typed in Description of the form Cat2, even though you have not yet explicitly committed the change in the form Cat2.</li> Open the Categories table. Note the first record contains the text that you typed for the Description in the Cat2 form.</li></ol>

<div class="references_section">