troubleshooting Question

FileSearc h in A2007

Avatar of Lawrence Salvucci
Lawrence SalvucciFlag for United States of America asked on
Microsoft AccessVB Script
9 Comments2 Solutions345 ViewsLast Modified:
I understand the FileSearch function is no longer available in A2007. Can anyone help me modify my code (created in 2003) to adapt this to work in 2007?
Function ImportFileDetails()
DoCmd.SetWarnings False

Dim fs, i, temp As Variant
Dim dbs As Database
Dim rst As Recordset
Dim sql As Variant
Dim msoSortByFileName As Variant
Dim msoSortOrderAscending As Variant

Set dbs = CurrentDb
Set fs = Application.FileSearch

sql = "D:\Doc Control\ISO\Doc Control\Level 3 QWI\" '(i.e. c:\")
On Error Resume Next
On Error GoTo 0
Set rst = dbs.OpenRecordset("tblDocListing")

With fs
    .LookIn = sql
    .SearchSubFolders = False
    .Filename = "*.*"
    If .Execute(SortBy:=msoSortByFileName, _
            SortOrder:=msoSortOrderAscending) > 0 Then
            'MsgBox "There were " & .FoundFiles.Count & _
            " file(s) found."
        For i = 1 To .FoundFiles.Count
            rst!DocFilePath = Left(.FoundFiles(i), InStrRev(.FoundFiles(i), "\"))
            rst!DocFileName = Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)
            rst!DocFileSize = FileLen(.FoundFiles(i))
            rst!DocFileModified = FileDateTime(.FoundFiles(i))
            'MsgBox .FoundFiles(i)
        Next i
        MsgBox "There were no files found."
    End If
End With

DoCmd.SetWarnings True
End Function
Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros