To work around this behavior, use either of the two methods listed for a Microsoft Access database (.mdb) file or the method listed for an Access project (.adp) file.
For a Microsoft Access database (.mdb) file
Method 1
Set the
RecordLocks property of the form to
Edited Record. To do so, follow these steps:
- Open the form in Design View.
Note In Access 2007, go to step 3. - On the View menu, click Properties.
- On the Data tab, change the Record Locks property to Edited Record.
Method 2
Add code to the OnDeactivate event procedure of both forms to save the record. To do so, follow these steps:
- Open the form in Design View.
Note In Access 2007, go to step 4. - On the View menu, click Properties.
- On the Edit menu, click Select Form.
- On the Event tab, right-click in the OnDeactivate property box, and then click Build.
- In the Choose Builder box, click Code Builder, and then click OK.
- Type or paste the following code:
DoCmd.RunCommand acCmdSaveRecord
- Open the second form in Design view and repeat steps 2 through 6.
For a Microsoft Access Project (.adp) file:
Add code to the OnDeactivate and OnActivate event procedures of both forms to save the record. To do so, follow these steps:
- Open the form in Design View.
Note In Access 2007, go to step 4. - On the View menu, click Properties.
- On the Edit menu, click Select Form.
- On the Event tab, right-click in the OnDeactivate property box, and then click Build.
- In the Choose Builder box, click Code Builder, and then click OK.
- Type or paste the following code:
DoCmd.RunCommand acCmdSaveRecord
- On the File menu, click Close and return To Microsoft Access.
- On the Event tab, right-click in the OnActivate property box, and then click Build.
- In the Choose Builder box, click Code Builder, and then click OK.
- Type or paste the following code:
Note The sample code in this article uses Microsoft ActiveX Data Objects. For this code to run correctly, you must reference the Microsoft ActiveX Data Objects 2.x Library (where 2.x is 2.1 or later). To do so, click
References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft ActiveX Data Objects 2.x Library check box is selected.
Dim rs As ADODB.Recordset
Set rs = Me.Recordset.Clone
rs.Bookmark = Me.Bookmark
DoCmd.RunCommand acCmdRefresh
Me.Bookmark = rs.Bookmark
rs.Close
Set rs = Nothing
- Open the second form in Design view, and then repeat steps 2 through 10.