ACC2000: Setting Form Recordset Causes Dirty Record to Commit

ID: Q223224


The information in this article applies to:
  • Microsoft Access 2000

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: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.


  2. Create a form called Cat1 with the following characteristics:


  3. 
       Form: Cat1
       ------------------------
       Caption: Cat1
       RecordSource: Categories
    
       Text Box
       -------------------------
       Name: CategoryID
       ControlSource: CategoryID
    
       Text Box
       --------------------------
       Name: Description
       ControlSource: Description 
  4. Create a second form called Cat2 with the following characteristics:


  5. 
       Form: Cat2
       -------------------------
       Caption: TestForm
       RecordSource: Categories
    
       Text Box
       -------------------------
       Name: CategoryID
       ControlSource: CategoryID
    
       Text Box
       --------------------------
       Name: Description
       ControlSource: Description 
  6. Open both forms in Form view, each on the first record.


  7. In form Cat2, change the Description to the following text, and leave the pointer in the field. Do not press ENTER.


  8. Beer, ales, teas, coffees, and soft drinks
  9. Press CTRL+G to open the Immediate window.


  10. Type the following in the Immediate window:


  11. 
    Set Forms("Cat1").Recordset = Forms("Cat2").Recordset 
  12. 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.


  13. Open the Categories table. Note the first record contains the text that you typed for the Description in the Cat2 form.



REFERENCES

For more information about the Recordset property, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type "recordset property" in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: pra dirty

Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: June 28, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.