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_Proj ectsTable"
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
sDir = Application.CurrentProject
sTable1 = "tbl_Projects"
sFile1 = "PROJECTS.TXT"
With Application.FileSearch
.NewSearch
.LookIn = Application.CurrentProject
.FileName = sFile1
.MatchTextExactly = True
If .Execute() > 0 Then
DoCmd.Hourglass True
'Delete existing lists
DoCmd.SetWarnings False
DoCmd.OpenQuery "qdel_AllRecords_from_Proj
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If Dir(CurrentProject.Path & "\PROJECTS.TXT") <> "" Then
'/file exists
Else
Msgbox "Import File Not Found"
End If