Microsoft KB Archive/116065

= ACC2: OnError Property Does Not Trap Locking Error in Form =

Article ID: 116065

Article Last Modified on 7/8/2002

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q116065



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



SYMPTOMS
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
 Open the sample database NWIND.MDB. Make sure to clear the Exclusive check box in the Open Database dialog box. Open the Employees form in Design view. Set the form's OnError property to:

=MsgBox("An error has occurred.")

 From the View menu, choose Options. In the Category box, select Multiuser/ODBC. In the Items box, set Default Record Locking to No Locks.</li> Save and close the Employees form.</li> Start another instance of Microsoft Access, or start Microsoft Access on another computer.</li> 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.</li> In both copies of Microsoft Access, open the Employees form in Form view.</li> In both copies of Microsoft Access, edit the Title field of the first record.</li> In the second copy of Microsoft Access, move to the next record.</li> In the first copy of Microsoft Access, move to the next record. Note that the Error event is not triggered.</li></ol>

<div class="references_section">