Docmd.Close Error

G

gpeak

Hello -

I have a small Access program that I use for invoicing. I have a recurring
issue with docmd.close command, specifically I receive the message "This
action cannot be carried out while processing a form or report event."

This is a very basic program. This message seems to happen when I attempt
to close a form with no changes being made. In my code, I have the following:

Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click

DoCmd.Close

Exit_cmdExit_Click:
Exit Sub

Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click

End Sub

Any help would be appreciated.
 
K

Ken Snell \(MVP\)

If you do not give the arguments to the Close action, it assumes that the
active object is the one to be closed. Sometimes, that can be different from
the one you want.

Always be explicit when using the DoCmd.Close method to close the form in
which the code is running:

DoCmd.Close acForm, Me.Name, acSaveNo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top