Check if form is open (1 Viewer)

Tracy

Registered User.
Local time
Today, 00:09
Joined
Oct 19, 2001
Messages
71
Hello (again),

Does anyone know how to check in VBA if a form is open?

Thanks
 

wh00t

Registered User.
Local time
Today, 00:09
Joined
May 18, 2001
Messages
264
paste the following code as a public function

Code:
Public Function IsOpen(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in form view

    Const conDesignView = 0
    Const conObjStateClosed = 0
    
    IsOpen = False
    
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
        
        If Forms(strFormName).CurrentView <> conDesignView Then
            IsOpen = True
        End If
    End If

End Function

and use it to check that a form is open by the following

e.g. If IsOpen("SomeForm") Then
MsgBox "yeah it's open"
End If
 

Tracy

Registered User.
Local time
Today, 00:09
Joined
Oct 19, 2001
Messages
71
Thank you very much.
 

Users who are viewing this thread

Top Bottom