Checking to see if a MDI Form is open

Checking to see if a MDI Form is open

I have an MDI application; when I Unload one form I want to check to see if another form is open and if it is run some code that refreshes it.I’ve tried using

if frmname.visible=true 

to see if its open but this doesn’t work (it loads up the form if it isn’t open).How do I check to see if a form is open?

If the target form is loaded, it will be included in the Forms collection. In the Unload event of the first form, call a RefreshForm procedure that loops through the Forms collection and looks for the desired form. If it’s there, refresh it:

   Private Sub Form_Unload(Cancel As Integer)       Call RefreshForm(frmOne)   End Sub   Public Sub RefreshForm(frmTarget As Form)       Dim frm As Form       For Each frm In Forms           If frm Is frmTarget Then               ' Call your refresh               ' code here           End If       Next   End Sub


Share the Post: