|
-
Jan 13th, 2000, 06:56 PM
#1
Thread Starter
Hyperactive Member
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, 10:56 PM
#2
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.
-
Jan 13th, 2000, 11:00 PM
#3
You can check the Forms Collection for a Certain Form, if it's there, then it's been loaded, otherwise it hasn't, ie.
Code:
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
[email protected]
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|