It may be that if the form is closed, you will be able to execute your statement
Code:
Application.DoCmd.Quit
So to close your form, you can use a statement like
Code:
docmd.openform "anotherForm",,,,,achidden 'count the commas for the hidden thing (air code)
docmd.close acform, Me.name
In the form named "anotherform" you can include the original statement that is likely causing the error. Maybe you can put it in the form's On Load, On Activate, or the On Current event. Maybe bind the form to a small recordset and place the following in the On Current.
Code:
Application.DoCmd.Quit