Solved

Application.FileSearch.Execute() not working

Posted on 2007-11-29
3
1,598 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now