Dan Waters
dwaters at usinternet.com
Mon Oct 31 09:47:25 CST 2005
Great!!
Thanks John - That's a simple solution!
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
papparuff at comcast.net
Sent: Monday, October 31, 2005 9:20 AM
To: Access Developers discussion and problem solving; AccessD
Cc: Dan Waters
Subject: Re: [AccessD] Find File in Folder and in Subfolder
This will work for you Dan,
Public Sub FindFileInSubFolders(strMainFolder As String, strFileToFind As
String)
Dim fso As New FileSystemObject
Dim fsoFolder As folder
Dim fsoSubFolder As folder
Dim fsoFile As File
Set fsoFolder = fso.GetFolder(strMainFolder)
For Each fsoSubFolder In fsoFolder.SubFolders
' Debug.Print fsoSubFolder.Name
For Each fsoFile In fsoSubFolder.Files
' Debug.Print fsoFile.Name
If fsoFile.Name = strFileToFind Then
MsgBox "Found File"
End If
Next fsoFile
Next fsoSubFolder
Set fsoFolder = Nothing
Set fsoFile = Nothing
Set fso = Nothing
End Sub
--
John V. Ruff - The Eternal Optimist :-)
"Commit to the Lord whatever you do,
and your plans will succeed." Proverbs 16:3
-------------- Original message --------------
> I have a customer who wants their application to be able to find a file in
a
> folder or subfolder based on the entry in a text box. The data entered is
a
> part number, and the file to be found is the drawing for that part.
>
> However, their file structure is inconsistent. I've looked at FSO, but
that
> requires that the path to a file be known. DIR is a help with the
> file/folders at the first level.
>
> Is there something that will search all the levels within a folder for a
> specific file?
>
> Thanks!
> Dan Waters
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com