On Dectivate: Close Form - doesn't work!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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)
 
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.
 
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.
 
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.
 
Back
Top