Modal form doesn't work like I thought.....

DataMiner

Registered User.
Local time
Today, 20:31
Joined
Jul 26, 2001
Messages
336
Hi,
I want my code to open a form, then halt until the form closes. I thought that opening the form in dialog mode would do this. However, for example, when I run a test like:

DoCmd.OpenForm "msgboxauto", , , , , acDialog
MsgBox "This is the regular msgbox"


Both the msgboxauto form and the regular msgbox show up at the same time. In fact, the msgbox seems to take precedence; I can't do anything else until I close the msgbox.

Am I misunderstanding something?

If I run this instead:
DoCmd.OpenForm "msgboxauto", , , , , acDialog
docmd.openform "SomeOtherForm"
MsgBox "This is the regular msgbox"

It seems to work like I expect. So is it just something weird with msgbox, or what???

My purpose here is to have a form "msgboxauto" work like a msgbox but close automatically after a given period of time. This is to keep my app from hanging because someone forgot to click "OK" in a msgbox. I thought making it a dialog box was the way to go, but....???
 
Something else is going on because the line after your OpenForm ...acDialog should *not* execute until you close the form opened with the OpenForm command.
 
I may be losing my mind..... right after I posted this, I checked again and it seemed to be working right.

At any rate, here's what I found out:

Doing it this way doesn't work:

DoCmd.OpenForm "msgboxauto",acdesign,achidden
{change the message on the form, etc.}
docmd.openform "msgboxauto",,,,,acdialog
MsgBox "This is the regular msgbox"

This seems to ignore the acdialog parameter.

Doing it this way works OK:

DoCmd.OpenForm "msgboxauto",acdesign,,,,achidden
{change the message on the form, etc.}
docmd.Close acForm,"msgboxauto",acSaveYes
docmd.openform "msgboxauto",,,,,acdialog
MsgBox "This is the regular msgbox"

Now it behaves like I wanted: the code halts until I close msgboxauto.
 
Thanks for posting back with your success. That is exactly how I would expect the code to function.
 

Users who are viewing this thread

Back
Top Bottom