Link to home
Start Free TrialLog in
Avatar of iomosaic
iomosaic

asked on

Application.FileSearch.Execute() not working

.Execute() always return 0 even though the file is in the searching folder. I have MS office 2003. Can someone help me?

sDir = Application.CurrentProject.Path
    sTable1 = "tbl_Projects"
    sFile1 = "PROJECTS.TXT"
   
        With Application.FileSearch
            .NewSearch
            .LookIn = Application.CurrentProject.Path
            .FileName = sFile1
            .MatchTextExactly = True
           
            If .Execute() > 0 Then
           
         
                DoCmd.Hourglass True
       
                'Delete existing lists
                DoCmd.SetWarnings False
                DoCmd.OpenQuery "qdel_AllRecords_from_ProjectsTable"
                DoCmd.SetWarnings True
               
                'Import updated lists
                DoCmd.TransferText acImportDelim, , sTable1, sDir & "\" & sFile1, True
               
                'Success
                MsgBox "Project List Update Complete."
            Else
                MsgBox "Import file not found"
            End If
        End With
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Are you trying to determine if the file PROJECTS.TXT exists in the current project's path? If so, a much easier way is like this:

If Dir(CurrentProject.Path & "\PROJECTS.TXT") <> "" Then
  '/file exists
Else
  Msgbox "Import File Not Found"
End If
Avatar of iomosaic
iomosaic

ASKER

but the code works on my other machine. I'm wondering if three is some issue with references that I'm overlooking?
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial