Detect if form is opened

  • Thread starter Thread starter JR_06062005
  • Start date Start date
J

JR_06062005

I need to detect if a form is open and if so, close it from another form. Is
there a code to detect if a particular form is opened?
 
I use this code:

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.

' These variables are used to test the return values of the SysCmd function
' and the CurrentView property of the requested form.
Const conObjStateClosed = 0
Const conDesignView = 0

'The first If statement uses the SysCmd function to check the current
'state of the requested form. It can be in one of four states: not open
'or nonexistent, open, new, or changed but not saved.
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then

'The second If statement checks for the current view of the
requested
'form, assuming the previous If statement found it to be open. If
'the form is currently open in Form View, the function will return
'true. If the form is in Design View, the function will return
false.
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If

End If

End Function

Mike from Moriches
 
Back
Top