This shows how to list the Documents in the Forms container:
Function ListMyForms()
Dim db As DAO.Database
Dim dox As DAO.Documents
Dim doc As DAO.Document
Dim strForm As String
Set db = DBEngine(0)(0)
Set dox = db.Containers("Forms").Documents
For Each doc In dox
strForm = doc.Name
Debug.Print strForm
Next
End Function
If you are actually wanting to change something for each form, you
probably need to open each one in turn, and modify its properties:
Function FixMyForms()
Dim db As DAO.Database
Dim dox As DAO.Documents
Dim doc As DAO.Document
Dim strForm As String
Set db = DBEngine(0)(0)
Set dox = db.Containers("Forms").Documents
For Each doc In dox
strForm = doc.Name
Debug.Print strForm
DoCmd.OpenForm strForm, acDesign, WindowMode:=acHidden
With Forms(strForm)
'set your properties here.
End With
DoCmd.Close acForm, strForm, acSaveYes
Next
Set doc = Nothing
Set dox = Nothing
Set db = Nothing
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Kevin S. said:
How do I get the documents collection? I've been trying to do that
because help said so, but I can't figure it out.
Allen Browne said:
In Access 2000 and later, you can use:
Dim accObj As AccessObject
For each accObj In CurrentProject.AllForms
...
In older versions, you can use the Documents collection in the
Containers to get the list of forms, or this (undocumented) query:
SELECT [Name] FROM MsysObjects
WHERE (([Type] = -32768) AND ([Name] Not Like '~*'))
ORDER BY MsysObjects.Name;
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
I need to get a list of all forms, but application.forms only gets open
ones. How can I get all of them?
dim frm as form
for each frm in _________________ ??
'yada yada
next frm