0

Hi Guys!

I just need a little help on how to detect if a form is open or loaded.? When it is loaded or open, i want it to show or visible when a button is click..

Something like this...

if frmisOpen(frmname)=true then
   'show or load the form
end if

Thank you & God bless us.!

Edited by blocker: n/a

5
Contributors
7
Replies
9
Views
6 Years
Discussion Span
Last Post by blocker
0

Use the instance method of the object(form) to check one instance is already running..

Edited by Pgmer: n/a

0

Sorry there is no such method called instance.
We need to write custome code to check.

0
Private Shared _Instance As Form1 = Nothing

    Public Shared Function Instance() As Boolean
        If _Instance Is Nothing OrElse _Instance.IsDisposed = True Then
            _Instance = New Form1
            Return False
        End If
        _Instance.BringToFront()
        Return True
    End Function

Try this

0

the simple way :)

Private Sub Command1_Click()
If Form2.Visible = True Then
'form is loaded
MsgBox ("Form 2 is loaded")
Else
MsgBox ("Form not loaded")
End If
End Sub

You can do that first by adding a public flag[do that in a module so you can access it anywhere], when form is loaded change it's value to 1. In button click if flag =1 then the form is loaded .

Private Sub Command1_Click()
If Flag = 1 Then
'form is loaded
MsgBox ("Form 2 is loaded")
Else
MsgBox ("Form not loaded")
End If
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub

Change Flag when form2 closes

Private Sub Form_Load()
Flag = 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Flag = 0
End Sub

Edited by Vineeth K: n/a

0

thank you guys for the answers..Any way, both solutions just solved it..just a combination of setting the flag and form instances..

Thank You!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.