Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 28th, 2005, 10:21 AM
flyersguy85 flyersguy85 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 1 flyersguy85 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 8 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old July 5th, 2005, 03:42 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
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

Reply With Quote
  #3  
Old July 5th, 2005, 04:27 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Need a little help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT