FileSystemObject - Compile Error Invalid use of property

R

rsampcss

Simplfied version of my code is below. I am trying to iterate through all the
subfolders searching for .MDB files which I will then open and get the value
of a column. In setting up the code to recursively go through the folders, I
am getting an "Invalid use of property" compile error on the "fc2 = ..."
statement below. I fail to see the difference between the "fc =
f.SubFolders" and "fc2 = fold1.SubFolders" statements. The fc= statement
works and the other gets an error.
I am using Access 2002 (3rd party product creates the MDBs).


Private Sub Command4_Click()
On Error GoTo Err_Command4_Click
Dim fso, f, fold1
Dim fc As Folders, fc2 As Folders
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\temp")
Set fc = f.SubFolders
For Each fold1 In fc
fc2 = fold1.SubFolders
Next fold1

Exit_Command4_Click:
Exit Sub

Err_Command4_Click:
MsgBox Err.Description
Resume Exit_Command4_Click

End Sub
 
R

rsampcss

Never mind. I need to add "Set" before fc2=. Of course I did not notice this
until the minute after I posted the question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top