View Full Version : Test if a form is open then close it


David Mack
10-09-2000, 08:58 AM
I know I've seen this somewhere before...

What I need to do is test if a form is open (which could be true or false depending on the user's circumstances) and close programically it if a true is returned.

I know how to test if a table exists in the tabledefs collection and then delete the table, but I cannot find out how to close a form if it is detected as open.

Thank you,

Dave Mack

David Mack
10-09-2000, 12:04 PM
Found it in the developer's handbook.
If the form "frmSurvey" is open, IsOpen returns a -1. Then close it.

Dim IsOpen As Integer

IsOpen = SysCmd(acSysCmdGetObjectState, acForm, "frmSurvey")
If IsOpen <> 0 Then
DoCmd.Close acForm, "frmSurvey", acSaveYes
End If

Dave Mack