FileSearch takes a long time (1 Viewer)

hqengint

Registered User.
Local time
Today, 23:09
Joined
Jul 16, 2002
Messages
13
I have a program that will search for files. I only want the 'FileSearch' command to return files that occur after a specified date that the user inputs. I use the 'PropertyTest.Add' method of the 'FileSearch' command and it works, but it takes way too long. In fact, it takes so long that I went to the task manager to end the program. Task Manager indicated that Access was not responding. However, if I just let the program run for a long time it would work. I know that the problem lies within the 'PropertyTest' method because I ran the program excluding that statement and it only took a few seconds. Is there a problem with my code that is making the program run really slow, or is that just the way it is? I appreciate any advice. My code follows:

With Application.FileSearch
.NewSearch
.LookIn = "D:\Shared"
.SearchSubFolders = True
.FileName = "*op*.txt"
'.PropertyTests.Add Name:="Last Modified", Condition:=msoConditionAnytimeBetween, Value:=ModifiedDate, SecondValue:=Date
.Execute
If .FoundFiles.Count > 0 Then
Set newtbl = CurrentDb.CreateTableDef("FoundFiles")
Set fld = newtbl.CreateField("FileName", dbText)
fld.OrdinalPosition = 1
newtbl.Fields.Append fld
CurrentDb.TableDefs.Append newtbl
Set rec = CurrentDb.OpenRecordset("FoundFiles")
For i = 1 To .FoundFiles.Count
rec.AddNew
rec("FileName") = .FoundFiles(i)
rec.Update
Next i
rec.Close
DoCmd.Close acForm, "FileSearch"
DoCmd.OpenForm "FoundFiles"
Else: MsgBox "No new OpLogs were found in the selected directory!"
End If
End With
 

Travis

Registered User.
Local time
Today, 15:09
Joined
Dec 17, 1999
Messages
1,332
Check out this site: VbNet

It is mainly written for VB, but it has good discriptions on how to use Window API's. There are some File Searching API's that might speed things up for you.
 

Users who are viewing this thread

Top Bottom