Public Sub test()
On Error Resume Next
Dim frm As AccessObject
Dim ctrl As Access.Control
For Each frm In CurrentProject.AllForms
DoCmd.OpenForm frm.Name, acDesign, , , acFormReadOnly, acHidden
For Each ctrl In Forms(frm.Name)
Debug.Print ctrl.Name
Next ctrl
DoCmd.Close acForm, frm.Name
Next frm
End Sub
Public Sub test()
On Error Resume Next
Dim frm As AccessObject
Dim ctrl As Access.Control
Dim frmOpen as Form
Dim blnClose As Boolean
For Each frm In CurrentProject.AllForms
Set frmOpen=Forms(frm.Name)
blnClose=(Err.Number<>0)
Err.Clear
If blnClose Then
DoCmd.OpenForm frm.Name, acNormal, , "0=1", , acHidden
End If
For Each ctrl In Forms(frm.Name)
Debug.Print ctrl.Name
Next ctrl
If blnClose Then
DoCmd.Close acForm, frm.Name
End If
set frmOpen=Nothing
Next frm
End Sub
The differences:
- acDesign cannot be used in MDE, so open the form in normal view, but hidden
- If the form has a data source, filter it so that no records are returned (0=1)
- close only the forms that were opened by the procedure
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.