PDA

Click to See Complete Forum and Search --> : Active form


Rick H
Jan 13th, 2000, 05:56 PM
How can I tell if a form is active from a function?

What I want to do is have a check box menu item to open/close a window. But I need a way to tell if its open so I know to close it and not open it (if you see what I mean!)

Thanks in advance

Jan 13th, 2000, 09:56 PM
If you have a form called Form1 and it is not loaded, if you write :

Unload Form1

No error is generated. If Form1 is loaded, it will unload.

So, go ahead and load & unload the forms according to your program's needs.

Aaron Young
Jan 13th, 2000, 10:00 PM
You can check the Forms Collection for a Certain Form, if it's there, then it's been loaded, otherwise it hasn't, ie.

Private Sub Command1_Click()
If IsLoaded("Form2") Then MsgBox "Form2 Is Already Loaded"
End Sub

Private Function IsLoaded(ByVal sFormName As String) As Boolean
For Each Form In Forms
If LCase(Form.Name) = LCase(sFormName) Then
IsLoaded = True
Exit For
End If
Next
End Function



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com