Code:
Public Function FormStatus(frms As Form) As String
If frms.Visible = True Then 'Your problem is here. This LOADS the form.
FormStatus = "open"
'MsgBox FormStatus
Else
FormStatus = "close"
'MsgBox FormStatus
End If
End Function
Any time you refer to the form or to a control on the form, the form is loaded.
Here is an easy way to get around that problem. Put this code in frmModal.
Code:
Option Explicit
Private mLoaded As Boolean
Private Sub Form_Load()
IsLoaded = True
End Sub
Public Property Get IsLoaded() As Boolean
IsLoaded = mLoaded
End Property
Public Property Let IsLoaded(ByVal bTF As Boolean)
mLoaded = bTF
End Property
Private Sub Form_Unload(Cancel As Integer)
IsLoaded = False
End Sub
Then in frmMain you can do this:
Code:
Private Sub Command1_Click()
If frmModal.IsLoaded Then
MsgBox "frmModal is loaded"
Else
MsgBox "frmModal is not loaded"
End If
End Sub