• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

FileSystemObject Search subfolders

I have created an applicantion to catalogue files in a folder.  My main procedure is listed below.  However, if possible I would like to include a checkbox option on my form to allow the user to enable searching for files in subfolders.  Any ideas?  

Public Sub CreateFileList(strTable As String, strFol As String)
Dim fs As New FileSystemObject
Dim fol As Folder
Dim fil As File

On Error GoTo ReportError

'Check to see if the table exists and if not create it
If Not DoesTableExist(strTable) Then
  Call CreateFileTable(strTable)
End If
Set fol = fs.GetFolder(strFol)

For Each fil In fol.Files

   CurrentDb.Execute "INSERT INTO " & strTable & " ([Filename],[Size],[DateCreated],[DateLastModified],[Hyperlink]) SELECT """ & fil.Name & """,""" & fil.Size & """,#" & fil.DateCreated & "#,#" & fil.DateLastModified & "#, """ & fil.Path & """"

Next

ExitHere:
  On Error Resume Next
  Exit Sub

ReportError:
  Dim msg As String
  If Err.Number <> 0 Then
    msg = "Error in Program" _
      & vbCr & "Error number " & CStr(Err.Number) _
      & " was generated by " & Err.Source _
      & vbCr & Err.Description
    MsgBox msg, vbExclamation, "Error"
  End If
  Resume ExitHere

End Sub
0
BillPowell
Asked:
BillPowell
1 Solution
 
jjafferrCommented:
Hi BillPowell,

Here you go:
http://www.experts-exchange.com/Databases/MS_Access/Q_20963136.html

I hope this helps.

jaffer
0
 
BillPowellAuthor Commented:
Yes it did.  I was totally unaware of the ability to call a procedure recursively.
Thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now