I have an Access 97 application that displays all of the databases in a particular directory by parsing through the FileSearch results. Unfortunately, on WindowsNT it includes the targets of any shortcuts as well.
For instance, in one directory I have the following files...
MyAccessDB.mdb
MyAccessDBShortcut (points to previous file)
MyRouterShortcut.mdb (points to a networked db)
When I run the FileSearch routine, I get all three files. Here's the code that I use in the file search...
Set objFS = Application.FileSearch
With objFS
If (iFile < 2) Then
.NewSearch
End If
.LookIn = lDir
.FileName = sExt
.FileType = msoFileTypeAllFiles
.MatchTextExactly = True
.SearchSubFolders = True
If .Execute(SortBy:=msoSortByFileType, SortOrder:=msoSortOrderAscending) > 0 Then
For i = iFile + 1 To .FoundFiles.Count
tFile = ""
tFile = Dir(.FoundFiles(i))
If (UCase(Left(.FoundFiles(i), Len(lDir))) <> UCase(lDir)) Then
GoTo NextFile
End If
If (Len(Trim(tFile) & " "
> 1) Then
HPC_GetAllFiles = .FoundFiles(i)
iFile = i
GoTo GetOutOfHereAndCloseDown
End If
NextFile:
Next i
Exit Function
End If
End With
Set objFS = Nothing
(I should point out that the "sExt" variable coming into the search containts "*.mdb;*.mde;*.mda;".)
What am I doing wrong? Glenn J. Koster, Sr.
High Plains Consulting
For instance, in one directory I have the following files...
MyAccessDB.mdb
MyAccessDBShortcut (points to previous file)
MyRouterShortcut.mdb (points to a networked db)
When I run the FileSearch routine, I get all three files. Here's the code that I use in the file search...
Set objFS = Application.FileSearch
With objFS
If (iFile < 2) Then
.NewSearch
End If
.LookIn = lDir
.FileName = sExt
.FileType = msoFileTypeAllFiles
.MatchTextExactly = True
.SearchSubFolders = True
If .Execute(SortBy:=msoSortByFileType, SortOrder:=msoSortOrderAscending) > 0 Then
For i = iFile + 1 To .FoundFiles.Count
tFile = ""
tFile = Dir(.FoundFiles(i))
If (UCase(Left(.FoundFiles(i), Len(lDir))) <> UCase(lDir)) Then
GoTo NextFile
End If
If (Len(Trim(tFile) & " "
HPC_GetAllFiles = .FoundFiles(i)
iFile = i
GoTo GetOutOfHereAndCloseDown
End If
NextFile:
Next i
Exit Function
End If
End With
Set objFS = Nothing
(I should point out that the "sExt" variable coming into the search containts "*.mdb;*.mde;*.mda;".)
What am I doing wrong? Glenn J. Koster, Sr.
High Plains Consulting