ACC2000: No Match Results in FileSearch When Adding FileType

ID: Q208811


The information in this article applies to:

This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).

Advanced: Requires expert coding, interoperability, and multiuser skills.


SYMPTOMS

When you search for file extensions by using the FileType property of the FileSearch object, certain file extensions may return a "files found = 0" message, even though the information does exist.

For example, this behavior occurs if you search for information on any of the following file extensions:

SYS
DLL
VXD
DRV
386


CAUSE

When you search for files that are hidden by default by Windows, they are excluded from indexing and content searching if the FileType property is included.


RESOLUTION

Do not include the FileType property if the file extension is not normally found in the Files of type box in the File Open dialog box. See the "Steps to Reproduce Problem" section of this article for an example of code that will search for these file types properly.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a module and type the following line in the Declarations section if it is not already there:


  2. 
    Option Explicit 
  3. Type the following procedure:


  4. 
    Sub TestSearch()
       Dim objFS As Object
    
       Set objFS = Application.FileSearch
    
       With objFS
    
          '  Resets all the search criteria settings to their default
          '  settings.
          .NewSearch
    
          '  Where to search in Windows 95. For Windows NT 4.0, change
          '  the path to "C:\Winnt\System32\".
          .LookIn = "C:\Windows"
    
          '  This will limit the search.
          .FileType = msoFileTypeAllFiles
    
          .FileName = "*.SYS"
    
          '  Search for "WinDir" within a file. This string is present
          '  in the file, MSDOS.SYS, in Windows 95. For Windows NT 4.0,
          '  change to "Invalid."
          .TextOrProperty = "WinDir"
    
          '  Limit the search to the root.
          .SearchSubFolders = False
    
          '  Begin the search.
          .Execute
      End With
    
       ' Show the number of files found.
       MsgBox "Files found = " & objFS.FoundFiles.Count
    
    End Sub 
  5. To test this function, type the following line in the Immediate window, and then press ENTER:
    
    TestSearch 
    Note that the message box opens and displays the following message:


  6. 
       Files found = 0 
  7. Comment out the line of code that sets the FileType property by placing an apostrophe (') in front of the line, as follows:


  8. 
    ' .FileType = msoFileTypeAllFiles 
  9. Rerun the procedure.

    Note that the message box displays the correct count for the files that contain the search string.



REFERENCES

For more information about the FileSearch object, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type "FileSearch object" in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words:


Keywords          : kbdta GnlFnd 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 13, 1999