Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to List all properties of a object

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
Lets say I have this code
Dim f As Folder, sf As Folder, fi As File

and I type fi. (F I Period) and a list of items (Properties or Attributes) comes up that I can choose. Is there a way to write a for loop to print each of them so I can see them?

example
for Each attribute in fi
debug.print f1????
next

if I press fi. I see
Attributes
Copy
DateCReated
...
ShortPath
Size
Type

TIA

DougP
 
Code:
Dim i as Integer

For i = 0 To fi.Properties.Count -1
  Debug.Print "Property Name: " & fi.Properties(i).Name & " - Value: " & fi.Properties(i).Value
Next i

John
 
Get Error on .Properties
For i = 0 To fi.Properties.Count -1

Error: Method or data member not found



DougP
 
you might want to play with these
Code:
Public Function fncControlProperties(theControl As Access.Control) As String
  On Error GoTo errLabel:
  Dim prop As Property
  Dim strProp As String
  strProp = "[code]"
  For Each prop In theControl.Properties
    strProp = strProp & " " & prop.Name & " " & prop.Value & vbCrLf
  Next prop
  fncControlProperties = strProp & vbCrLf & "
"
Exit Function
errLabel:
If Err.Number = 2187 Or Err.Number = 2186 Then
Resume Next
Else
MsgBox Err.Number & Err.Description
Resume Next
End If
End Function

Public Function fncformProperties(theForm As Access.Form) As String
On Error GoTo errLabel:
Dim prop As Property
Dim strProp As String
strProp = "
Code:
" & vbCrLf
  For Each prop In theForm.Properties
    strProp = strProp & " " & prop.Name & " Value:" & prop.Value & vbCrLf
  Next prop
  fncformProperties = strProp & "
"
Exit Function
errLabel:
If Err.Number = 2187 Or Err.Number = 2186 Then
Resume Next
Else
MsgBox Err.Number & Err.Description
End If
End Function

Public Sub documentForm()
Dim strName As String
Dim frm As AccessObject
strName = InputBox("Ensure form is loaded and enter Form Name.", "Input Form")
For Each frm In CurrentProject.AllForms
If frm.Name = strName Then
'If Not frm.IsLoaded Then
DoCmd.OpenForm strName, , , , , acHidden
Debug.Print fncformProperties(Forms(strName))
DoCmd.Close acForm, strName
Exit Sub
'End If
End If
Next frm
MsgBox "Form not found."
End Sub

[/code]

and if you want to do some serious documenting
 
I do not believe that the file object of the FileSystemObject has a properties collection.
 
How are ya DougP . . .

Agree with [blue]Remou[/blue]! There is no [blue]properties[/blue] or [blue]attributes[/blue] collection to loop thur!

You have to access them individually!

Properties are:
[tt][blue] Attributes
DateCreated
DateLastAccessed
dateLastModified
Drive
Name
ParentFolder
Path
ShortName
ShortPath
Size
Type[/blue][/tt]

Attributes are:
[tt][blue] Alias
Archive
Compressed
Directory
Hidden
Normal
ReadOnly
System
Volume[/blue][/tt]

[blue]Your thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
You may use the Object Browser (F2 when in VBE)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top