Function IsLoaded(ByVal strFormName As String) As Integer
'======================================
'Returns True if the specified form is open in Form view or Datasheet view.
'Test to make sur that a form is open (IsLoaded) before a procedure is run.
'======================================
On Error GoTo ErrHandler
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
Exit Function
ErrHandler:
MsgBox "Error: " & Err.Number & " - " & Err.Description, vbInformation, "Opps Error"
Exit Function
End Function