ACC2: OnError Property Does Not Trap Locking Error in Form

ID: Q116065


The information in this article applies to:


SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

If you have a form's RecordLocks property set to No Locks and a multiuser record locking error occurs, the form's Error event is not triggered, and the normal "This record has been changed by another user since you started editing it..." dialog box appears.


CAUSE

The Error event is triggered when a run-time error is produced in Microsoft Access. The multiuser record locking error mentioned above is not a trappable run-time error.


STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.


MORE INFORMATION

The Error event is triggered when a run-time error is produced in Microsoft Access. If you set the form's OnError property to a macro or event procedure, Microsoft Access will run the macro or event procedure when a run-time error occurs.

If you set a form's RecordLocks property to No Locks, no error will be trapped when two users modify the same record at the same time. Instead, Microsoft Access will display a dialog box to the user who attempted to save the record last, prompting the user to save the changes, discard the changes, or copy the changes to the Clipboard.

Steps to Reproduce Problem


  1. Open the sample database NWIND.MDB. Make sure to clear the Exclusive check box in the Open Database dialog box.


  2. Open the Employees form in Design view.


  3. Set the form's OnError property to:
    =MsgBox("An error has occurred.")


  4. From the View menu, choose Options.


  5. In the Category box, select Multiuser/ODBC. In the Items box, set Default Record Locking to No Locks.


  6. Save and close the Employees form.


  7. Start another instance of Microsoft Access, or start Microsoft Access on another computer.


  8. In the second instance of Microsoft Access, or on the other computer, open the same NWIND.MDB file. Make sure to clear the Exclusive check box in the Open Database dialog box.


  9. In both copies of Microsoft Access, open the Employees form in Form view.


  10. In both copies of Microsoft Access, edit the Title field of the first record.


  11. In the second copy of Microsoft Access, move to the next record.


  12. In the first copy of Microsoft Access, move to the next record. Note that the Error event is not triggered.



REFERENCES

For more information about Error events, search for "error events," and then "Error and Timing Events" using the Microsoft Access Help menu.

Microsoft Access "User's Guide," version 2.0, pages 107 and 224

Additional query words: optimistic


Keywords          : kbusage FmsProp 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 3, 1999