Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine if a form is loaded? 2

Status
Not open for further replies.

vietnam97

Programmer
Sep 18, 2000
48
Hi,

Can you tell me if there is a function or some ways to tell if a particular form is loaded?

Thanks,
Bao
 
look for thread222-40125 or thread222-27619 _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
form or app, for the app:

if app.PrevInstance then
exit sub 'as the program is already open
endif


for the form try this:

Private Sub Command1_Click()
Dim frm As Form 'declare a form object
For Each frm In Forms 'Forms is the collection of all loaded forms
If frm.Name = "Form1" Then MsgBox "It is open"

Next frm

Set frm = Nothing
End Sub


Troy Williams B.Eng.
fenris@hotmail.com

 
Try this

Code:
Function FormState(FormName As String) As String
    Dim frm As Form
    For Each frm In Forms
        If StrComp(frm.Name, FormName, vbTextCompare) = 0 Then
            If frm.Visible = True Then
                FormState = "Shown"
                Exit Function
            Else
                FormState = "Loaded"
                Exit Function
            End If
        End If
    Next
    FormState = "Unloaded"
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top