JimMiller
01-30-2002, 06:46 AM
I am looking for the code when given a form name will return if the form is loaded or not loaded in the system. Does anyone know the syntax or other ways to achieve my objective?
Thanks!
Thanks!
|
View Full Version : Code for verifying if a form is loaded JimMiller 01-30-2002, 06:46 AM I am looking for the code when given a form name will return if the form is loaded or not loaded in the system. Does anyone know the syntax or other ways to achieve my objective? Thanks! JimMiller 01-30-2002, 07:21 AM Never mind. I figured it out. Below is a way to loop through all the loaded forms... Sub CloseForms() Dim i As Integer For i = (Forms.Count - 1) To 0 Step -1 If Forms(i).Name <> "MainForm" Then DoCmd.Close acForm, Forms(i).Name End If Next i End Sub Loop through the open forms (a form will be in the FORMS collection only if it is open). Change "MainForm" to the name you do not want to close. The loop must run in reverse since the form index numbers change when a form is closed (that is, if you close form(2), then all forms with a higher index are renumbered). If you try this code with the loop index running up from 0 it won't close all the forms. |