Article ID: 248011 - View products that this article applies to.
This article was previously published under Q248011
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access database (.mdb).
This article shows you how use Data Access Objects (DAO) to control transactions in a form that is based on a table (a bound form) in a Microsoft Access (Jet) database.
Typically, a developer needs to be able to let users of a database application commit all or none of their data changes on a form. In versions of Access earlier than version 2000, you could not encapsulate data changes made on bound forms within transactions. This was because all transactions in bound forms were handled in a separate workspace, accessible only to Microsoft Access.
In Microsoft Access 2000, however, you can use a combination of Data Access Objects (DAO) and the new, form Recordset property to provide this capability. The example in this article assumes that the user wants to be prompted to commit all changes made to the form's data when the user closes the form. At that time, the user can either commit all of the changes or none of the changes.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.
NOTE: This example is designed to work with single main forms. It is not designed to work with linked subforms.
Controlling Transactions on Bound Forms