|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need a little help
OK here is my code so far:
With Application.FileSearch .LookIn = "C:\Documents and Settings\kqdx564\My Documents\test" If .Execute() > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count Me!List156 = .FoundFiles(i) Next i Else MsgBox "There were no files found." End If End With I wrote this for a previous database that I had been working on and made a few changes since I have been playing with it. I need to do 2 things. 1) Take search criterea out of a text box (Text159) and search for files that have that in it (not exact match) and then I want to display the search results in the list box (List156). Right now I don't have the filename part, but the list box part is inside the for loop and for some reason isn't working. Any help would be greatly appreciated. |
|
#2
|
|||
|
|||
|
I don't believe you will be able to do a file search using wild cards. However you can fill the list box with the list of files from your .LookIn Change the syntax slightly
Dim strList As String With Application.FileSearch .LookIn = "C:\Documents and Settings\kqdx564\My Documents\test" If .Execute() > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count strList = strList & .FoundFiles(i) & ";" Next i Else MsgBox "There were no files found." End If End With strList = Left(strList, Len(strList) - 1) List156.RowSource = strList Make sure your listbox property is set to Value List lwells |
|
#3
|
|||
|
|||
|
Correction to prior post to add your search textbox
Dim strList As String Dim strSearch As String strSearch = Text159 & "*" With Application.FileSearch .LookIn = "C:\Documents and Settings\kqdx564\My Documents\test" .FileName = strSearch If .Execute() > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count strList = strList & .FoundFiles(i) & ";" Next i Else MsgBox "There were no files found." End If End With strList = Left(strList, Len(strList) - 1) List156.RowSource = strList |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Need a little help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|