Quickly List the Properties of an Object in Access
Many objects in the Office object model include a Properties
collection, including the following objects in Microsoft Access:
- Database
- Form
- Report
- QueryDef
- Control
Here's a quick routine that loops through an object's Properties collection, outputting the index, name, and value of each property to the immediate window. This is a handy debugging tool.
The Code
Public Sub ListProperties(obj As Object)
Dim i As Long
For i = 0 To obj.Properties.Count - 1
On Error Resume Next
Debug.Print Right(" " & i, 4); " ";
Debug.Print Left(obj.Properties(i).Name & Space(30), 30); " ";
Debug.Print obj.Properties(i).Value;
'print a blank line every three rows to improve readability
If i Mod 3 = 2 Then Debug.Print
Debug.Print
'pause the output after every 50 properties
' as a quick and dirty form of pagination
If i Mod 50 = 49 Then Stop 'press F5 to continue
Next i
End Sub
Here's a sample usage: