Solved

Application.FileSearch.Execute() not working

Posted on 2007-11-29
3
1,611 Views
Last Modified: 2013-11-28
.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
0
Comment
Question by:iomosaic
  • 2
3 Comments
 
LVL 84
ID: 20374233
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
0
 

Author Comment

by:iomosaic
ID: 20374281
but the code works on my other machine. I'm wondering if three is some issue with references that I'm overlooking?
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 20375164
Possibly, or it could be disabled. The FSO can be disabled by an antivirus engine or network admin (which is why I avoid it altogether).
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question