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
|
|
0
|
|
|
|
Reply
|
Utf
|
4/21/2010 3:34:01 PM |
|
Never mind. I need to add "Set" before fc2=. Of course I did not notice this
until the minute after I posted the question.
"rsampcss" wrote:
> 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
>
>
>
|
|
0
|
|
|
|
Reply
|
Utf
|
4/21/2010 3:41:03 PM
|
|