Closing a form with VBA

  • Thread starter OfficeDev18 via AccessMonster.com
  • 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
 
D

Dirk Goldgar

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?
 
J

John Griffiths

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
 
G

Guest

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
 
O

OfficeDev18 via AccessMonster.com

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]
 
O

OfficeDev18 via AccessMonster.com

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]
 
G

Guest

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]
 
R

Rob Oldfield

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
 
J

John Griffiths

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/>
 

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