M
Marshall Barton
TonyAntique said:How can I test if the same form is already loaded?
The following in frmTest always returns true.
Private Sub Form_Open(Cancel As Integer)
If CurrentProject.AllForms("frmTest").IsLoaded = True Then
Form_frmTest.visible = True
Cancel = True
End If
End Sub
I want to stop a second existence of a form opening / loading, and making the
existing form visible if hidden.
I don't see how that can happen unless you go out of your
way to write code that can create multiple instances of a
specific form.
For sure, you can not open the same form twice using
OpenForm or from tha Database window. If you try to do
that, you will see that all OpenForm does is make it visible
and set the focus to the already open instance.
You also can not reliably use Form_frmTest syntax to
reference the already open form. That syntax refers to the
default instance of the form's class module and is primarily
useful along with the New keyword when using code to create
multiple instances of a form.
Bottom line is if you use OpenForm, you will not have the
situation you are concerned about.