See if form is open

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

When opening a form, I'd like to check and see if a
different form is already open. If not, I do not want to
open the form. What kind of code could I use for this?

Thanks in advance,

Jason
 
Hi Jason,

Try the following function:

if isloaded("form1") then
msgbox "Form1 is loaded"
endif

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

Or in Access 2000 and above you can test the AllForms collection of the
CurrentProject object.

if CurrentProject.allforms("form1").isloaded then
msgbox "Form1 is loaded"
endif
 
Thanks - just what I was looking for!

Jason
-----Original Message-----
Hi Jason,

Try the following function:

if isloaded("form1") then
msgbox "Form1 is loaded"
endif

Public Function IsLoaded(ByVal strFormName As String) As Integer
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm,
strFormName) said:
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function

Or in Access 2000 and above you can test the AllForms collection of the
CurrentProject object.

if CurrentProject.allforms("form1").isloaded then
msgbox "Form1 is loaded"
endif

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

When opening a form, I'd like to check and see if a
different form is already open. If not, I do not want to
open the form. What kind of code could I use for this?

Thanks in advance,

Jason
.
 
Back
Top