In a module in the modules window, copy/paste the following function:
Code:
[blue]Public Function IsOpenForm(frmName As String) As Boolean
If CurrentProject.AllForms(frmName).IsLoaded Then
IsOpenForm = True
End If
End Function[/blue]
Thank you very much TheAceMan1 for all your help. While I was waiting for replies I used this approach:
Dim strformName As String
Const conObjStateClosed = 0
Const conDesignView = 0
strformName = "frm_findInvoicePU"
If SysCmd(acSysCmdGetObjectState, acForm, strformName) <> conObjStateClosed Then
If Forms(strformName).CurrentView <> conDesignView Then
MsgBox "Open " & strformName 'My code will go here
Be aware: a form can be open in [blue]Form View[/blue] or [blue]Design View[/blue]!
The point being, the code you posted explicitly tests if the form is open in [blue]Form View[/blue], whereas the [blue]IsLoaded[/blue] property returns true for either view!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.