Determining if a form is open

  • Thread starter Thread starter Jim Pockmire
  • Start date Start date
From VBA Help on the AllForms collection, here is one way:

Sub AllForms()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub

hth,
 
Is there a way using visual basic to determine if a form is open or not?
Try this...
------------------------------
Public Function IsOpen(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view.

Const conDesignView = 0
Const conObjStateClosed = 0

IsOpen = False
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> _
conObjStateClosed Then

If Forms(strFormName).CurrentView <> conDesignView Then
IsOpen = True
End If
End If
End Function
 
Back
Top