Solved

Populate Access Table with names of documents in a folder

Posted on 2011-09-08
6
256 Views
Last Modified: 2012-05-12
I have written Access VBA Code that opens a folder and displays all the documents in that folder.

QUESTION:

How do I use the FileSystemObject to populate a table with the document names?

I would greatly appreciate some help

Biggles1
0
Comment
Question by:Biggles1
6 Comments
 
LVL 12

Assisted Solution

by:danishani
danishani earned 100 total points
ID: 36503477
Check this nice Function out of Allen Browne:
http://www.everythingaccess.com/tutorials.asp?ID=List-files-to-a-table

Hope this helps,
Daniel
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 400 total points
ID: 36503484


Sub gFiles()

Dim initPath As String, strFile As String
Dim objFSO, objFdr
   initPath = "C:\ Folder1\Folder2\"
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   Set objFdr = objFSO.GetFolder(initPath)
        strFile = Dir(initPath & "\*.*")
        Do Until strFile = ""
           
            'your code to add the filenames to the table

            strFile = Dir
        Loop

End Sub
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 36503532
capricorn1,

Have not use the FSO for a couple of years, but when I did, I generally found that it was quite a bit slower than just using DIR() to loop through the various folders and files.  Do you know if this is still the case?
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 36503569

@fyed- yes, i think that is one of the reason why i use Dir() in my recursive search code.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 36503581
the link that danishani posted above http:#a36503477 have the recursive search codes
0
 
LVL 26

Expert Comment

by:Nick67
ID: 36504294
It'd help if you posted the code you have already.
I assume you have a FileDialog object on the go.
<opens a folder and displays all the documents in that folder>
And I suspect that the .Show is opening Windows Explorer window.

It's not that hard to take the vrtSelectedItem from that, and then do a GetFolder, GetFiles, and loop once through the Files collection, writing records to a table

The structure and name of the table would be nice to know too because the loop will be something like

dim rs as recordset
set rs = currentdb.openrecordset("select * from SomeTable where 1=2;",dbopendynaset)
for each myFile in myFiles
    with rs
       .addnew
       !PathName = vrtItemSelected
       !FileName = myfile.name
       .update
    end with
loop

But I can't do the syntax up without REALLY knowing what you have on the go.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now