On Dectivate: Close Form - doesn't work!

A

Adam Thwaites

Private Sub Form_Deactivate()
Me.SetFocus
DoCmd.Close acForm, "frm_Hobbies"
End Sub

Is bringing up the error: 2585
'This action can't be carried out while processing a form or report event'

Anyone got any clues?
--
Adam Thwaites
Access Database Designer
Manchester, UK
(I have no access to other sites apart from microsoft.com so posting
external links is no use to me)
 
D

David C. Holley

Executing the DoCmd.Close statement will trigger the CLOSE event, as
well as the related events such as UNLOAD and probably DEACTIVATE. These
will all occurr in a specific sequence, wether or not you have code tied
to the events. Since you're calling the statement from the Form's
DEACTIVATE event, you're probably creating a conflict for Access. I'm
not the expert on when and which events fire when a form closes, however
if you check Access help under OnClose I believe that there's the
sequence of events is listed there.
 
K

Klatuu

On which line is the error raised?
My guess is the Me.SetFocus line. Try commenting it out and running a test.
I am not sure what you are trying to accomplish, but it is likely not
necessary. A form will not accept the focus if there are any controls on the
form capable of taking the focus anyway.
 
A

Adam Thwaites

No, it's on the line:
DoCmd.Close acForm, "frm_Hobbies"

The setfocus isn't always necassary but I put it there after somehow the
main form closed instead. Most of the time it doesn't make a difference.
 

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