Function IsLoaded(ByVal strFormName As String) As Boolean
'Returns True if the specified form is open in Form view or Datasheet view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
If IsLoaded("yourFormNameHere") then
'whatever when form is open
Else
'whatever when form is closed
End if
but how does that work with multiple form instances?
Dim frm1 As New Form_MyForm
Dim frm2 As New Form_MyForm
frm1.Visible=True
frm2.Visible=True
But someone much clever than I might know a better solution.
And that's how I learnThen you need to use hWnd property to differentiate between the two instances.
Not sure what you mean here. A particular form can only be open, or closed. You can several different forms open at the same time though?.
I personally use something very similar Craig's offering especially if more than one instance when I need to check the form's status.
And that's how I learn![]()
my version is 2003 and 2007, i got both
but how does that work with multiple form instances? because that's my case, i want to check for few forms
i was just going to make few IF statements
i'm sure there's a better way, if you got time, can you explain?
If CurrentProject.AllForms("fprojectS").IsLoaded Then
[Forms]![fprojectS]![Status].Requery
[Forms]![fprojectS]![StatusL].Requery
End If
If CurrentProject.AllForms("freportsanalyst").IsLoaded Then
[Forms]![freportsanalyst]![Status].Requery
[Forms]![freportsanalyst]![StatusL].Requery
[Forms]![freportsanalyst]![PROJECTS.Status].Requery
[Forms]![freportsanalyst]![PROJECTS.StatusL].Requery
End If
The generic part of the function doesn't need a form name, you only add it from wherever you want to use so you only need to add the form name onceok, i understand all that
but copy what, the whole IF statement?
and how is it gonna help me if i still have to change the names of forms and fields everytime i use it
what am i missing?