Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Application.FileSearch.Execute() not working

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

792 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