Hello,
I am having problems with the FileSystemObject. I have set a variable equal to a folders files as a collection. I then want to set a vriable equal to the first item of that collection, which should be the first file of that folder. I then increase my counter so that the next time the sub is called it will grab item # 2 u, etc. I get an error 5 illegal procedure call. Any help would be appreciated.

Private Function GetFileSize(rstSource As Recordset)
Dim fso As Object, flec, fldr, fleCurrent
Dim strSubFolder As String, strCurrFileName As String

Set fso = CreateObject("Scripting.FileSystemObject")

If intFolderCount <= 9 Then
strSubFolder = "Image00" & Trim(intFolderCount)
Else
strSubFolder = "Image0" & Trim(intFolderCount)
End If

strOldImCompPath = strOldImagePath & strSubFolder & "\"

Set fldr = fso.GetFolder(strOldImCompPath)
Set flec = fldr.Files
Set fleCurrent = flec.Item(lngFileCount) ' this is the line it bombs on

The the rest of the function


lngFileCount = lngFileCount + 1
If lngFileCount > flec.Count Then
intFolderCount = intFolderCount + 1
lngFileCount = 1
End If


strCurrFileName = CStr(fleCurrent.Name)
If Mid(rstSource![Record #], 1, 5) = Mid(strCurrFileName, 1, 5) Then
GetFileSize = fleCurrent.Size
Else
lngFileCount = lngFileCount - 1
GetFileSize = 0
End If

Set fso = Nothing
Set fldr = Nothing
Set flec = Nothing
Set fleCurrent = Nothing

End Function