Testing for an open form

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

Guest

Can anyone tell me how to test whether a form is open or not i.e. it is not
the active form but is open.
What I want to do is use this in an event procedure of the active form as
follows:

If FormXXX is open then do something

Thanks
 
PRH said:
Can anyone tell me how to test whether a form is open or not i.e. it
is not the active form but is open.
What I want to do is use this in an event procedure of the active
form as follows:

If FormXXX is open then do something

In Access 2000 or later, you can use

If CurrentProject.AllForms("FormXXX").IsLoaded Then
' ...
End If

In Access 97, there's a much-posted function named "IsLoaded" that you
can use. I'll post it if you need it, or you can search Google Groups
for it.
 
I would appreciate it if you could post the "IsLoaded" function for Access97
and if possible explain how I set it up within Access.

Thanks
 
Take a look in the Northwind Database that came with Access. The IsLoaded
function is located in the Utility Functions module.
 
PRH said:
I would appreciate it if you could post the "IsLoaded" function for
Access97 and if possible explain how I set it up within Access.

From the Northwind sample database:

'----- start of code -----
Function IsLoaded(ObjectName As String, _
Optional ObjectType As Integer = acForm) _
As Boolean

If SysCmd(acSysCmdGetObjectState, ObjectType, ObjectName) _
= acObjStateOpen _
Then
Select Case ObjectType
Case acForm
If Forms(ObjectName).CurrentView <> 0 Then
IsLoaded = True
End If
Case Else
IsLoaded = True
End Select
End If

End Function
'----- end of code -----

Just paste the code into a standard module (on the Modules tab of the
database container window). If you create a new standard module for the
purpose, don't give it the same name as the function.
 
Back
Top