Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FileSystemObject Search subfolders

Posted on 2004-10-22
2
Medium Priority
?
197 Views
Last Modified: 2012-06-21
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
Comment
Question by:BillPowell
[X]
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
2 Comments
 
LVL 27

Accepted Solution

by:
jjafferr earned 2000 total points
ID: 12385198
Hi BillPowell,

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

I hope this helps.

jaffer
0
 
LVL 11

Author Comment

by:BillPowell
ID: 12385722
Yes it did.  I was totally unaware of the ability to call a procedure recursively.
Thanks!!!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

618 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