R
Rich K
I'm using the application.filesearch to find files that have file path files
that fulfill certain text comparisons.
This is what my code looks like:
Dim vItem As Variant
Dim db As DAO.Database
Dim searchString As String
Dim searchLocation As String
searchString = Nz(Me.txtSearchString.Value, "")
searchString = Replace(searchString, "_", "[_]")
searchString = Replace(searchString, "#", "[#]")
searchLocation = Nz(Me.txtSearchLocation.Value, "")
Select Case Me.SearchType.Value
Case 1
searchString = searchString & "*"
Case 2
searchString = "*" & searchString
Case 3
searchString = "*" & searchString & "*"
Case Else
End Select
Set db = CurrentDb
With Application.FileSearch
.FileName = searchString
.LookIn = searchLocation
.MatchTextExactly = False
.SearchSubFolders = True
.Execute
For Each vItem In .FoundFiles
Me.lisFiles.AddItem vItem
Next vItem
End With
Set db = Nothing
-------------------------------------------------------------------
that fulfill certain text comparisons.
This is what my code looks like:
Dim vItem As Variant
Dim db As DAO.Database
Dim searchString As String
Dim searchLocation As String
searchString = Nz(Me.txtSearchString.Value, "")
searchString = Replace(searchString, "_", "[_]")
searchString = Replace(searchString, "#", "[#]")
searchLocation = Nz(Me.txtSearchLocation.Value, "")
Select Case Me.SearchType.Value
Case 1
searchString = searchString & "*"
Case 2
searchString = "*" & searchString
Case 3
searchString = "*" & searchString & "*"
Case Else
End Select
Set db = CurrentDb
With Application.FileSearch
.FileName = searchString
.LookIn = searchLocation
.MatchTextExactly = False
.SearchSubFolders = True
.Execute
For Each vItem In .FoundFiles
Me.lisFiles.AddItem vItem
Next vItem
End With
Set db = Nothing
-------------------------------------------------------------------