devxlogo

Checking to see if a MDI Form is open

Checking to see if a MDI Form is open

Question:
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?

Answer:
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
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist