Re: Closing Form Produces "Runtime Error 2585"

G

Graham Mandeno

Hi Kevin

DoCmd.Close can behave asynchronously and works on the form which currently
has the focus, so I suspect what is happening is that sometimes you are
attempting to close the MainMenu form while it is in the act of opening.

Always specify what you want to close:
DoCmd.Close acForm, Me.Name

I see you say you have already tried this, but try it again anyway :)

My main concern is that you should NEVER store an easily calculatable entity
such as Full Name like this. It is so easy to make a query with a
calculated field to give you the Full Name from its component parts as and
when you need it, and in the format required for the purpose.

I recommend you remove the Full Name field from your table.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Kevin Rodriguez said:
I have a procedure that runs on Click from a form. The code, in brief:

DoCmd.RunSQL "UPDATE Contacts SET Contacts.[Full Name] = [LastName] &
', ' & [FirstName] & ' ' & [Title]"
DoCmd.Close
DoCmd.OpenForm "MainMenu"

I'm getting the above referenced error (error message: This action can't
be carried out while processing a form or report event), but not all the
time. I can't figure out what is going on to have the error come up
randomly. I've tried to run it without the SQL statement before the close,
it still fails. I've been explicit including "acForm said:
I'm a novice and wondering if I set one of my properties incorrectly, or
what ever...
 
G

Guest

I agree with you on the calculated full name. It's a legacy item that I have to work with for the time being. I'll remove this blight on my data model later

I tried the "DoCmd.Close acForm, Me.Name" and it didn't work

I then tried "DoCmd.Close acForm, Screen.ActiveForm" and got runtime error 2475 - You entered an expression that requires a form to be the active window. So your thought is right. Perhaps the focus is changed before the form is closed. It's just a rookie guess and I don't know how or why this could happen. I continue to be baffled

----- Graham Mandeno wrote: ----

Hi Kevi

DoCmd.Close can behave asynchronously and works on the form which currentl
has the focus, so I suspect what is happening is that sometimes you ar
attempting to close the MainMenu form while it is in the act of opening

Always specify what you want to close
DoCmd.Close acForm, Me.Nam

I see you say you have already tried this, but try it again anyway :-

My main concern is that you should NEVER store an easily calculatable entit
such as Full Name like this. It is so easy to make a query with
calculated field to give you the Full Name from its component parts as an
when you need it, and in the format required for the purpose

I recommend you remove the Full Name field from your table
--
Good Luck

Graham Mandeno [Access MVP
Auckland, New Zealan


Kevin Rodriguez said:
I have a procedure that runs on Click from a form. The code, in brief
DoCmd.RunSQL "UPDATE Contacts SET Contacts.[Full Name] = [LastName]
', ' & [FirstName] & ' ' & [Title]
DoCmd.Clos
DoCmd.OpenForm "MainMenu
be carried out while processing a form or report event), but not all th
time. I can't figure out what is going on to have the error come u
randomly. I've tried to run it without the SQL statement before the close
what ever..
 
G

Graham Mandeno

Hi Kevin

That's strange ... closing the current form and opening another one is a
very common practice.

Does it work if you comment out the DoCmd.RunSQL? If it does, try moving
that line to the Form_Unload procedure and use CurrentDb.Execute instead:
CurrentDb.Execute "UPDATE....."
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Kevin Rodriguez said:
I agree with you on the calculated full name. It's a legacy item that I
have to work with for the time being. I'll remove this blight on my data
model later.
I tried the "DoCmd.Close acForm, Me.Name" and it didn't work.

I then tried "DoCmd.Close acForm, Screen.ActiveForm" and got runtime error
2475 - You entered an expression that requires a form to be the active
window. So your thought is right. Perhaps the focus is changed before the
form is closed. It's just a rookie guess and I don't know how or why this
could happen. I continue to be baffled.
----- Graham Mandeno wrote: -----

Hi Kevin

DoCmd.Close can behave asynchronously and works on the form which currently
has the focus, so I suspect what is happening is that sometimes you are
attempting to close the MainMenu form while it is in the act of opening.

Always specify what you want to close:
DoCmd.Close acForm, Me.Name

I see you say you have already tried this, but try it again anyway :)

My main concern is that you should NEVER store an easily calculatable entity
such as Full Name like this. It is so easy to make a query with a
calculated field to give you the Full Name from its component parts as and
when you need it, and in the format required for the purpose.

I recommend you remove the Full Name field from your table.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


I have a procedure that runs on Click from a form. The code, in brief:
DoCmd.RunSQL "UPDATE Contacts SET Contacts.[Full Name] =
[LastName] &
', ' & [FirstName] & ' ' & [Title]"
DoCmd.Close
DoCmd.OpenForm "MainMenu"
can't
be carried out while processing a form or report event), but not all the
time. I can't figure out what is going on to have the error come up
randomly. I've tried to run it without the SQL statement before the close,
it still fails. I've been explicit including "acForm, <FormName>" on the
DoCmd, it still fails. I'm at a loss. incorrectly, or
what ever...
 
G

Guest

I already tried it without the DoCmd.RunSQL and it didn't work

----- Graham Mandeno wrote: ----

Hi Kevi

That's strange ... closing the current form and opening another one is
very common practice

Does it work if you comment out the DoCmd.RunSQL? If it does, try movin
that line to the Form_Unload procedure and use CurrentDb.Execute instead
CurrentDb.Execute "UPDATE.....
--
Good Luck

Graham Mandeno [Access MVP
Auckland, New Zealan

Kevin Rodriguez said:
I agree with you on the calculated full name. It's a legacy item that
have to work with for the time being. I'll remove this blight on my dat
model later2475 - You entered an expression that requires a form to be the activ
window. So your thought is right. Perhaps the focus is changed before th
form is closed. It's just a rookie guess and I don't know how or why thi
could happen. I continue to be baffled
----- Graham Mandeno wrote: ----
Hi Kevi
DoCmd.Close can behave asynchronously and works on the form whic
currentl
has the focus, so I suspect what is happening is that sometimes yo ar
attempting to close the MainMenu form while it is in the act o opening
Always specify what you want to close DoCmd.Close acForm, Me.Nam
I see you say you have already tried this, but try it again anywa :-
My main concern is that you should NEVER store an easily calculatabl
entit
such as Full Name like this. It is so easy to make a query with
calculated field to give you the Full Name from its component part as an
when you need it, and in the format required for the purpose
I recommend you remove the Full Name field from your table
--
Good Luck
Graham Mandeno [Access MVP Auckland, New Zealan
I have a procedure that runs on Click from a form. The code, i brief
DoCmd.RunSQL "UPDATE Contacts SET Contacts.[Full Name]
[LastName] &> ', ' & [FirstName] & ' ' & [Title]
DoCmd.Clos
DoCmd.OpenForm "MainMenu
I'm getting the above referenced error (error message: This actio
can'
be carried out while processing a form or report event), but not al th
time. I can't figure out what is going on to have the error come u
randomly. I've tried to run it without the SQL statement before th close
it still fails. I've been explicit including "acForm, <FormName>" o th
DoCmd, it still fails. I'm at a loss incorrectly, o
what ever..
 
G

Guest

I've found another piece of the puzzle, If I repair and compact the database, the next time I open the file my forms work properly. If I don't repair and compact, I get the error. I thinkI'm not properly closing out or unloading some stuff when I exit and thus leave a lot of junk that causing the problem. Like I said, I'm a novice. Am I missing a step when I close a form? I'm using DoCmd.RunSQL for all my database calls. I assume that this doen't leave any open database connections like when I call SQLServer

----- Kevin Rodriguez wrote: ----

I already tried it without the DoCmd.RunSQL and it didn't work

----- Graham Mandeno wrote: ----

Hi Kevi

That's strange ... closing the current form and opening another one is
very common practice

Does it work if you comment out the DoCmd.RunSQL? If it does, try movin
that line to the Form_Unload procedure and use CurrentDb.Execute instead
CurrentDb.Execute "UPDATE.....
--
Good Luck

Graham Mandeno [Access MVP
Auckland, New Zealan

Kevin Rodriguez said:
I agree with you on the calculated full name. It's a legacy item that
have to work with for the time being. I'll remove this blight on my dat
model later2475 - You entered an expression that requires a form to be the activ
window. So your thought is right. Perhaps the focus is changed before th
form is closed. It's just a rookie guess and I don't know how or why thi
could happen. I continue to be baffled
----- Graham Mandeno wrote: ----
Hi Kevi
DoCmd.Close can behave asynchronously and works on the form whic
currentl
has the focus, so I suspect what is happening is that sometimes yo ar
attempting to close the MainMenu form while it is in the act o opening
Always specify what you want to close DoCmd.Close acForm, Me.Nam
I see you say you have already tried this, but try it again anywa :-
My main concern is that you should NEVER store an easily calculatabl
entit
such as Full Name like this. It is so easy to make a query with
calculated field to give you the Full Name from its component part as an
when you need it, and in the format required for the purpose
I recommend you remove the Full Name field from your table
--
Good Luck
Graham Mandeno [Access MVP Auckland, New Zealan
I have a procedure that runs on Click from a form. The code, i brief
DoCmd.RunSQL "UPDATE Contacts SET Contacts.[Full Name]
[LastName] &> ', ' & [FirstName] & ' ' & [Title]
DoCmd.Clos
DoCmd.OpenForm "MainMenu
I'm getting the above referenced error (error message: This actio
can'
be carried out while processing a form or report event), but not al th
time. I can't figure out what is going on to have the error come u
randomly. I've tried to run it without the SQL statement before th close
it still fails. I've been explicit including "acForm, <FormName>" o the
DoCmd, it still fails. I'm at a loss. incorrectly, or
what ever...
 

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