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
-----------------------------------------------
I'll actual ask the question this time.
When using wildcards I have success when I use the * in the search, but when
I try to use wildcards for a single letter or number the process returns no
records. What is the process for using wildcards in searches other than *?
Thanks in advance.
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
-----------------------------------------------
I'll actual ask the question this time.
When using wildcards I have success when I use the * in the search, but when
I try to use wildcards for a single letter or number the process returns no
records. What is the process for using wildcards in searches other than *?
Thanks in advance.