Kev,
Why not just use
DoCmd.Close acForm, "formName"?
If the form is open it will close.
If the form is not open, nothing will happen.
If for some reason you did get an error, just trap it.
However, you may need to know if a form is open for other reasons, such as
cancelling a report if the associated dialog from has been closed.
So here is the IsLoaded function you can copy into a new module if you have
Access 97 or older:
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 call it from an event:
If Not IsLoaded("FormName") Then
etc.
End If
If you have Access 2000 or later you do NOT need the above function.
Access 2000-2002 includes the IsLoaded function in it's library.
Just use:
If Not CurrentProject.AllForms("Form2").IsLoaded Then
Do something here
Else
Do something else
End If