Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if form is open? 2

Status
Not open for further replies.

sstevie1

IS-IT--Management
Sep 30, 2004
2
US
1)I need to be able to check if a certain form is open.
2)Or I need to tell which forms are open and depending on a form name run code.


Many, many thanks!
 
How are ya sstevie1 . . .

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]
Returns true if frmName is open . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
which forms are open
Use the Application.Forms collection.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
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

End If
End If

Your way seems a lot more elegant.
 
sstevie1 . . .

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!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top