How can I tell if a form is already open

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to set a variable, and the value of the variable is based on the fact that a specified form is open on closed. I have no idea how to check to see if a form is open, any ideas....

Thanks,
Jerry
 
I need to set a variable, and the value of the variable is based on the fact that a specified form is open on closed. I have no idea how to check to see if a form is open, any ideas....

Thanks,
Jerry

What version of Access?
Access 2002:
If Not CurrentProject.AllForms("FormA").IsLoaded Then
Do something here
Else
Do something else
End If

Or in all versions, copy this function (from the Northwind.mdb sample
database).

Function IsLoaded(ByVal strFormName As String) As Integer
' 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

Then code:
If Not IsLoaded("FormA") Then
Do this
Else
Do that
End if
 
Back
Top