Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Difference between revisions of "Microsoft KB Archive/171193"

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 53: Line 53:
 
This article describes how to create a sample user-defined function that uses the FileSearch object contained in the Application object to locate a file on a particular drive.<br />
 
This article describes how to create a sample user-defined function that uses the FileSearch object contained in the Application object to locate a file on a particular drive.<br />
 
<br />
 
<br />
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the &quot;Building Applications with Microsoft Access 97&quot; manual.
+
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.
  
 
</div>
 
</div>
Line 74: Line 74:
 
         With Application.FileSearch
 
         With Application.FileSearch
 
             .FileName = strFileName
 
             .FileName = strFileName
             .LookIn = &quot;c:\&quot;
+
             .LookIn = "c:\"
 
             .SearchSubFolders = True
 
             .SearchSubFolders = True
 
             .Execute
 
             .Execute
Line 87: Line 87:
 
<div class="indent">
 
<div class="indent">
  
<p><span class="kbd userinput"> ?LocateFile(&quot;northwind.mdb&quot;)</span></p>
+
<p><span class="kbd userinput"> ?LocateFile("northwind.mdb")</span></p>
  
 
</div>
 
</div>
Line 99: Line 99:
 
== REFERENCES ==
 
== REFERENCES ==
  
For more information about using Visual Basic for Applications code to search for files, search the Help Index for &quot;FileSearch object,&quot; and then click FoundFiles in the object tree at the top of the FileSearch Object Help topic.
+
For more information about using Visual Basic for Applications code to search for files, search the Help Index for "FileSearch object," and then click FoundFiles in the object tree at the top of the FileSearch Object Help topic.
  
 
</div>
 
</div>

Latest revision as of 10:05, 21 July 2020

Knowledge Base


ACC97: Sample Procedure to Find the Location(s) of a File

Article ID: 171193

Article Last Modified on 1/20/2007



APPLIES TO

  • Microsoft Access 97 Standard Edition



This article was previously published under Q171193

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


SUMMARY

This article describes how to create a sample user-defined function that uses the FileSearch object contained in the Application object to locate a file on a particular drive.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.

MORE INFORMATION

The LocateFile() function takes the file that you are looking for as a string argument and returns all locations of that file. To create the function, follow these steps:

  1. Open the sample database Northwind.mdb.
  2. Create a module and type the following line in the Declarations section if it is not already there:

          Option Explicit
                            
  3. Type the following procedure:

          Function LocateFile(strFileName as String)
             Dim vItem As Variant
             With Application.FileSearch
                .FileName = strFileName
                .LookIn = "c:\"
                .SearchSubFolders = True
                .Execute
                For Each vItem In .FoundFiles
                   Debug.Print vItem
                Next vItem
             End With
          End Function
                            
  4. To test this function, type the following line in the Debug window, and then press ENTER:

    ?LocateFile("northwind.mdb")


    Note that all locations of Northwind.mdb are printed in the Debug window.


REFERENCES

For more information about using Visual Basic for Applications code to search for files, search the Help Index for "FileSearch object," and then click FoundFiles in the object tree at the top of the FileSearch Object Help topic.

Keywords: kbcode kbinfo KB171193