Wait for a form to Close: Alternative to dialog mode

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 23:28
Joined
Sep 12, 2006
Messages
16,030
I prefer not to use dialog mode with forms. I like sizeable and movable forms, and in many of my apps, I save form sizes and positions, so that uses can get the interface looking how they want.

So here is an alternative

open form with this code. Access will now wait for the form to close before continuing - which is the the same as dialog mode, but you now have a "normal" form appearance


Code:
docmd.openform "myform"
while isopen("myform")
   doevents
wend

.... waits for form to close
.... program execution continues

now the trouble is, there is no isopen function in vba - so this does the job.

Code:
Function IsOpen(strName As String, Optional objtype As Integer = acForm)
   IsOpen = (SysCmd(acSysCmdGetObjectState, objtype, strName) <> 0)
End Function

note that you can use this idea with a query, or a report also

Code:
docmd.openform "myreport"
while isopen("myreport",acreport)
   doevents
wend
 
Last edited:
Neat idea, gemma-the-husky. Though I will point out that Access draws a lot of CPU utilization when waiting on a form using your Rx.

I have been using the Properties \ Other \ Modal = Yes attribute of normal windows to insure users do not click elsewhere yet the form window remains re-sizable. Perhaps this Rx will be useful to others as well.
 

Users who are viewing this thread

Back
Top Bottom