View Full Version : Wait for a form to Close: Alternative to dialog mode


gemma-the-husky
07-03-2011, 01:57 AM
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


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.


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

docmd.openform "myreport"
while isopen("myreport",acreport)
doevents
wend

mdlueck
09-06-2011, 03:53 AM
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.