Closing a form with VBA

  • Thread starter Thread starter OfficeDev18 via AccessMonster.com
  • Start date Start date
O

OfficeDev18 via AccessMonster.com

Grrr!

I call a separate CloseForm() subroutine, where I try to close a previous
form, from the current form's OnOpen event. I keep getting run-time error
2585: "This action can't be carried out while processing a form or report
event.

How the heck else am I supposed to close the thing!? I tried calling it from
the previous form's Close() event, but got the same error.

My code is simple: DoCmd.Close acForm, "FormName"

Thanks,

Sam
 
OfficeDev18 via AccessMonster.com said:
Grrr!

I call a separate CloseForm() subroutine, where I try to close a
previous form, from the current form's OnOpen event. I keep getting
run-time error 2585: "This action can't be carried out while
processing a form or report event.

How the heck else am I supposed to close the thing!? I tried calling
it from the previous form's Close() event, but got the same error.

My code is simple: DoCmd.Close acForm, "FormName"

I don't see why that would be giving you a problem. What event, if any,
is the form you're trying to close processing? What's the code in that
event? What's the code in the new form's Open event?
 
I think this is the clue :-
"where I try to close a previous form"

If the previous form lauched the current form and is still in the event (ie
open a modal form) then this is the sort of behaviour I would expect.

Check stack trace to confirm that the previous form's event handler is
waiting to complete.

Regards John
 
How do you do a stack trace in VBA?

John Griffiths said:
I think this is the clue :-
"where I try to close a previous form"

If the previous form lauched the current form and is still in the event (ie
open a modal form) then this is the sort of behaviour I would expect.

Check stack trace to confirm that the previous form's event handler is
waiting to complete.

Regards John
 
To answer your implied question, I'm not opening the form modally.

Sam

John said:
I think this is the clue :-
"where I try to close a previous form"

If the previous form lauched the current form and is still in the event (ie
open a modal form) then this is the sort of behaviour I would expect.

Check stack trace to confirm that the previous form's event handler is
waiting to complete.

Regards John
[quoted text clipped - 11 lines]
 
Thanks to all who wrote.

I got the thing to work by a simple command button with the code DoCmd.Close
and nothing else.

Sam
To answer your implied question, I'm not opening the form modally.

Sam
I think this is the clue :-
"where I try to close a previous form"
[quoted text clipped - 12 lines]
 
There was no implied question to your. I was asking John Griffiths how you
do a stack trace in VBA. I am familiar with it from other environments, but
I was not even aware that functionality is available for VBA. I would like
to know how to do it.

OfficeDev18 via AccessMonster.com said:
To answer your implied question, I'm not opening the form modally.

Sam

John said:
I think this is the clue :-
"where I try to close a previous form"

If the previous form lauched the current form and is still in the event (ie
open a modal form) then this is the sort of behaviour I would expect.

Check stack trace to confirm that the previous form's event handler is
waiting to complete.

Regards John
[quoted text clipped - 11 lines]
 
It's just View, Call stack.


Klatuu said:
There was no implied question to your. I was asking John Griffiths how you
do a stack trace in VBA. I am familiar with it from other environments, but
I was not even aware that functionality is available for VBA. I would like
to know how to do it.

OfficeDev18 via AccessMonster.com said:
To answer your implied question, I'm not opening the form modally.

Sam

John said:
I think this is the clue :-
"where I try to close a previous form"

If the previous form lauched the current form and is still in the event (ie
open a modal form) then this is the sort of behaviour I would expect.

Check stack trace to confirm that the previous form's event handler is
waiting to complete.

Regards John

Grrr!

[quoted text clipped - 11 lines]

Sam
 
Yes (thats what I meant), something I've overlooked for years on the VBA
side of things in spite of using it in VB - John


Rob Oldfield said:
It's just View, Call stack.
<snip/>
 
Back
Top