View Full Version : Check if form is open


Vassago
06-12-2003, 11:03 AM
I basically need some code to check if a form is open. Basically, what I want to do is something like:

If form is open then
do this
else
do this
end if

Any ideas?

Thanks!

Vassago

ghudson
06-12-2003, 11:18 AM
Northwind has the IsLoaded function. I use this...

Private Sub Command1_Click()
If IsFormOpen("formA") = True Then
MsgBox "Form A is open"
Else
MsgBox "Form A is not open"
End If
End Sub

'Put this function in a public module
Function IsFormOpen(strFormName As String) As Boolean
IsFormOpen = (SysCmd(acSysCmdGetObjectState, acForm, strFormName) = acObjStateOpen)
End Function

HTH

Vassago
06-12-2003, 11:31 AM
I tried the Isloaded function and could not get it to work correctly, however..

Your solution works perfectly! Thank you!

Vassago