T
thriveni
I use access 2000.
I have a Function that uses to DIR function to locate some
folders, and then have another Function called from within
the loop of Dir, to do further processing on each these
folders. however the DIR loop exits after the first folder
and does not loop through. could this be because the
called Function uses the Filesearch object to retrieve
certain files ? If this Function is not called within the
DIR loop, the loop actually finds all the folders. I have
posted my code below. any help will be appreciated
Function process_source_dirs(myPath1 As String) As Boolean
Dim myName As String, mypath1 As String
Dim ret_val As Boolean, test_name As String
Dim county_path As String
Dim i As Integer
i = 1
myName = Dir(mypath1, vbDirectory) ' Retrieve the first
entry.
Do While myName <> "" ' Start the loop.
' Ignore the current directory and the encompassing
directory.
If myName <> "." And myName <> ".." Then
' Use bitwise comparison to make sure MyName is a
directory.
If (GetAttr(mypath1 & myName) And vbDirectory) =
vbDirectory Then
county_path = myPath & date_dir(i) & "\" & myName
get_county_code (myName)
'call the main function to go through each of
these directories
ret_val = getsubdirs(county_path) ' PROBLEM
here : does not loop through the while if this call is made
End If ' it represents a directory.
End If
myName = Dir ' Get next entry.
Wend
process_source_dirs = ret_val
End Function
Function getsubdirs(myPath As String) As Boolean
Dim fs As FileSearch
Dim intI As Integer
Set fs = Application.FileSearch
Dim myfile As TextStream
Dim book_num As Integer
Dim destination_image_name As String
Dim ret_val As Boolean
Dim logfile_name As String
With fs
.NewSearch
.filename = "*.tif"
.LookIn = myPath
.SearchSubFolders = True
.Execute
count = .FoundFiles.count
For intI = 1 To .FoundFiles.count
myPath = .FoundFiles.Item(intI)
.some processing here ...
'MsgBox myPath
Next
End With
I have a Function that uses to DIR function to locate some
folders, and then have another Function called from within
the loop of Dir, to do further processing on each these
folders. however the DIR loop exits after the first folder
and does not loop through. could this be because the
called Function uses the Filesearch object to retrieve
certain files ? If this Function is not called within the
DIR loop, the loop actually finds all the folders. I have
posted my code below. any help will be appreciated
Function process_source_dirs(myPath1 As String) As Boolean
Dim myName As String, mypath1 As String
Dim ret_val As Boolean, test_name As String
Dim county_path As String
Dim i As Integer
i = 1
myName = Dir(mypath1, vbDirectory) ' Retrieve the first
entry.
Do While myName <> "" ' Start the loop.
' Ignore the current directory and the encompassing
directory.
If myName <> "." And myName <> ".." Then
' Use bitwise comparison to make sure MyName is a
directory.
If (GetAttr(mypath1 & myName) And vbDirectory) =
vbDirectory Then
county_path = myPath & date_dir(i) & "\" & myName
get_county_code (myName)
'call the main function to go through each of
these directories
ret_val = getsubdirs(county_path) ' PROBLEM
here : does not loop through the while if this call is made
End If ' it represents a directory.
End If
myName = Dir ' Get next entry.
Wend
process_source_dirs = ret_val
End Function
Function getsubdirs(myPath As String) As Boolean
Dim fs As FileSearch
Dim intI As Integer
Set fs = Application.FileSearch
Dim myfile As TextStream
Dim book_num As Integer
Dim destination_image_name As String
Dim ret_val As Boolean
Dim logfile_name As String
With fs
.NewSearch
.filename = "*.tif"
.LookIn = myPath
.SearchSubFolders = True
.Execute
count = .FoundFiles.count
For intI = 1 To .FoundFiles.count
myPath = .FoundFiles.Item(intI)
.some processing here ...
'MsgBox myPath
Next
End With