What's the best way to check if form is open?

dungstar

Registered User.
Local time
Today, 01:41
Joined
Mar 13, 2002
Messages
72
I have two main forms referring to one subform. I want that particular subform's combobox to detect which main form it is running under with a series of if statements to perform a function.

Is there a simple way of the subform knowing which main form its running under? Or if I have another form two forms opened up, and I want one form to maybe pop a message box saying that the other form is open. What's the best way to check if form is open?
 
Use this function to test if a form is open...
Function IsFormOpen(strFormName As String) As Boolean
IsFormOpen = (SysCmd(acSysCmdGetObjectState, acForm, strFormName) = acObjStateOpen)
End Function

Call the function and test for a specific form (FormA) is open...
Private Sub Command1_Click()
If IsFormOpen("FormA") = True Then
MsgBox "Form A is open"
Else
MsgBox "Form A is not open"
End If
End Sub

HTH
 

Users who are viewing this thread

Back
Top Bottom