I've been struggling for over 1 year to resolve this bug being experienced on 2 of my 7 data input forms for one of my databases at work.
If you enter data into any text or combo box on the form, the record locks and a pencil appears in the corner. If you try to leave the form using the close form command button I've created, the user is prompted with an error saying "The RunCommand action was cancelled". As far as I can tell, this comes from the close form button's code:
DoCmd.RunCommand acCmdSaveRecord
When the pencil appears and the record is locked, the line of code in my close form button creates the run command error. I know this because if I put a ' before this line, the error goes away, but the record does not save.
The only way I've found to prevent this error, save the record, and close the form -- is to enter the data into the text box. Then press escape (which removes the pencil sign), then you can press the command button to close the form.
This "bug" (or maybe bad design on my part) has been plaguing 2 of my 7 forms - creating major confusion for some of my users. Any time a user edits a record, they have to first press escape to unlock the record, then they can press close form. The other 5 data input forms do not have this issue. You can change the data in a field no problem and just press the close form button (and the record saves).
Any ideas what is causing the record to be locked? Why can I press escape and the record becomes unlocked? Is this simulating a change in object focus? Is there a vba command I can send to mimick the escape key being pressed? I'm racking my brain here why this form locks until pressing escape, and why running a docmd save record command while locked would create a run command error.
If you enter data into any text or combo box on the form, the record locks and a pencil appears in the corner. If you try to leave the form using the close form command button I've created, the user is prompted with an error saying "The RunCommand action was cancelled". As far as I can tell, this comes from the close form button's code:
DoCmd.RunCommand acCmdSaveRecord
When the pencil appears and the record is locked, the line of code in my close form button creates the run command error. I know this because if I put a ' before this line, the error goes away, but the record does not save.
The only way I've found to prevent this error, save the record, and close the form -- is to enter the data into the text box. Then press escape (which removes the pencil sign), then you can press the command button to close the form.
This "bug" (or maybe bad design on my part) has been plaguing 2 of my 7 forms - creating major confusion for some of my users. Any time a user edits a record, they have to first press escape to unlock the record, then they can press close form. The other 5 data input forms do not have this issue. You can change the data in a field no problem and just press the close form button (and the record saves).
Any ideas what is causing the record to be locked? Why can I press escape and the record becomes unlocked? Is this simulating a change in object focus? Is there a vba command I can send to mimick the escape key being pressed? I'm racking my brain here why this form locks until pressing escape, and why running a docmd save record command while locked would create a run command error.