Picture this. I have a form that processes an order and updates several records on completion.
The form has a CANCEL button (for a new order) and an ABORT button for a changing order. The CANCEL procedure and the ABORT procedure both end by closing the form to return to the main form.

During the processing of an order (new or changing) the lights go out.

On restart of the application (after re-boot etc.) it is determined that the system did not do an orderly shutdown. A recovery procedure is initiated. This re-opens the transaction form in "recovery" mode. The incomplete transaction is located and a call is made (Call CmdCANCEL_Click for example) to terminate the order gracefully. This is the same procedure that would run if the CANCEL button was clicked. The RTE 2585 happens when this procedure does the DoCmd.Close acform Me.name.

It would appear that the Call to the procedure behaves quite differently than a button click.
I have tried several ways of doing this and did come up with an inelegant solution. The recovery routine opens the transaction form which calls the cancel/abort procedure which then simply ends without doing a close. The recovery routine then waits for 1 second and then closes the transaction form.

I have other simple forms that perform a function in the Load procedure and then finish with a DoCmd.Close and that works. Is it the Call that is getting Access upset? Can this be avoided?

Is there a cleaner way to get the form to open/call process/close?