tell if a form is open

  • Thread starter Thread starter geebee
  • Start date Start date
G

geebee

Hi,

I want to be able to write code to evaluate whether or
not a form is open. For example, if form A is open,
perform a certain action, else, perform another action.

Does anyone know the code to do this. I have run into
several snippets of code, but can't really interpret them.

Thanks in advance,
geebee
 
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
 
If you use A2K or later, you can also use:

CurrentProject.AllForms("FormName").IsLoaded

to check whether the Form is open or not.
 
HI,

Thanks for your response. I am not sure where to put the
folowing code you recommended:

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



Thanks in advance,
geebee
-----Original Message-----
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.
Hi,

I want to be able to write code to evaluate whether or
not a form is open. For example, if form A is open,
perform a certain action, else, perform another action.

Does anyone know the code to do this. I have run into
several snippets of code, but can't really interpret them.

Thanks in advance,
geebee
.
 
Hi Geebee,

Put it in a standard module - from the database window view modules and then
click new.


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

HI,

Thanks for your response. I am not sure where to put the
folowing code you recommended:

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



Thanks in advance,
geebee
-----Original Message-----
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

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

I want to be able to write code to evaluate whether or
not a form is open. For example, if form A is open,
perform a certain action, else, perform another action.

Does anyone know the code to do this. I have run into
several snippets of code, but can't really interpret them.

Thanks in advance,
geebee
.
 
Back
Top