What version of Access? In recent versions, you can loop through
CurrentProject.AllForms to get the names of the forms.
In Access 97 and earlier, read the Documents in the Forms container, or
(undocumented) read directly from the system tables:
SELECT [Name] FROM MsysObjects
WHERE (([Type] = -32768) AND ([Name] Not Like '~*'))
ORDER BY MsysObjects.Name;
Once you have the form names, open each form in turn, and loop through the
Controls collection. Here's the basic idea:
Function ShowAllControls()
Dim accobj As AccessObject
Dim strFormName As String
For Each accobj In CurrentProject.AllForms
strFormName = accobj.Name
DoCmd.OpenForm strFormName, acDesign, WindowMode:=acHidden
For Each ctl In Forms(strFormName).Controls
Debug.Print strFormName, ControlTypeName(ctl.ControlType),
ctl.Name
Next
DoCmd.Close acForm, strFormName
Next
End Function
Function ControlTypeName(n As Long) As String
'Purpose: Return the name of the ControlType.
'Note: The ControlType returns a Byte, but the constants are Long.
Dim strReturn As String
Select Case n
Case acBoundObjectFrame
strReturn = "Bound Object Frame"
Case acCheckBox
strReturn = "Check Box"
Case acComboBox
strReturn = "Combo Box"
Case acCommandButton
strReturn = "Command Button"
Case acCustomControl
strReturn = "Custom Control"
Case acImage
strReturn = "Image"
Case acLabel
strReturn = "Label"
Case acLine
strReturn = "Line"
Case acListBox
strReturn = "List Box"
Case acObjectFrame
strReturn = "Object Frame"
Case acOptionButton
strReturn = "Object Button"
Case acOptionGroup
strReturn = "Option Group"
Case acPage
strReturn = "Page (of Tab)"
Case acPageBreak
strReturn = "Page Break"
Case acRectangle
strReturn = "Rectangle"
Case acSubform
strReturn = "Subform/Subrport"
Case acTabCtl
strReturn = "Tab Control"
Case acTextBox
strReturn = "Text Box"
Case acToggleButton
strReturn = "Toggle Button"
Case Else
strReturn = "Unknown: type" & n
End Select
ControlTypeName = strReturn
End Function