How to close a frozen modal dialog form

I have several apps in Access 2007 that have a number of modal dialog forms.  When I am testing and trying to simulate user conditions and something in the modal dialog form fails, I am always forced to Ctrl-Alt-Delete and force quit the application.

Is there some command or shortcut that will allow me to close such a modal dialog while in an ACCDB so that I can continue my testing?  I can successfully do Ctrl-G and get into the immediate window, but then cannot figure what to do.  It seems like this should be a simple process, but I have never been able to figure out how to handle it.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chuck WoodCommented:
Type this in the Immediate window and press Enter:
-chuck wood
DoCmd.Close acForm,"FormName"

Open in new window

wsturdevAuthor Commented:
When I do that, I get "Compile Error.  Expected: End of Statement"
Chuck WoodCommented:
1. Did you use the name of the form for "FormName"?
2. Did you compile your code and save it before testing?
-chuck wood
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You have to use full syntax:

DoCmd.Close( acForm,"FormName")


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:

1. <something in the modal dialog form fails, I am always forced to Ctrl-Alt-Delete and force quit the application.>
"Something" fails?
Can you be a bit more specific?
I use Modal Dialog boxes in Access 2007 and they close with impunity.

2. Can you post some of your code that generates this mysterious failure, and state what line it fails on?

3. Clearly define what you mean by "modal dialog form".
Modal and Dialog are two separate, but related properties


Jeffrey CoachmanMIS LiasonCommented:
Perhaps something is being triggered "Behind" the form.
But since the form is modal/dialog, this "failure" cannot be acted upon.
wsturdevAuthor Commented:
I use "modal dialogs" a lot also, and once I get the code perfected, they work well and consistently.  
I am talking about while I am in the middle of developoment and still perfecting the code (sorry, I am not quite like those Papermate Pens... I don't write [perfect code] the first time, every time.).
I cannot be specific about what fails.  The failures are not "mysterious", and in fact, they do not matter in this case, because I will eventually write correct code.
I was just asking a general question about how to get out of a "modal dialog" that has had some kind of failure in its code that has sent it into Debug Mode, and from which I cannot continue.  I cannot bypass the offending statement and thus cannot get the form displayed completely enough so that I can then click the Cancel button and close it.
The "modal" property of the form is "No".  I open the form in this way:
    Dim stDocName As String
    stDocName = "Dialog_Blah_Blah_Blah"
    DoCmd.OpenForm stDocName, acNormal, , , , acDialog
The code in the calling form pauses processing until the "modal dialog" form is closed and control is returned to the next statement after the calling statement, and while the form is open, no action can be initiated by a user outside the form.  Eventually, the user must do something (e.g. click an Okay button or a Cancel button) to dismiss the "modal dialog" and allow processing on the calling form to continue.
I have always called such forms "Modal Dialogs".  Forgive me if I have used incorrect terminology.
Jeffrey CoachmanMIS LiasonCommented:

Obviously, this it is hard to troubleshoot with no sample code.

Perhaps another Expert has had this issue and can help you further...

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.