Solved

Read and load File names and date modified into a table from a FOLDER

Posted on 2016-08-17
7
41 Views
Last Modified: 2016-08-18
In access vba  - I would like to go to a specific folder (No sub folders) and grab a list of file names and their date modified and date created and put them in a table in 3 columns - [Filename] [DateMod] [DateCreate]  -  any ideas?
I use  
       string = Dir(path & "*.*", vbnormal)
to get filenames all the time but how do u get the dates and other attributes and load them in a table?
0
Comment
Question by:Grizbear51
7 Comments
 
LVL 75
ID: 41760316
I just have a moment, but you can easily do this with the File System Object.
If you set a Reference to the VB Scripting Object ... you will have full intellisense.
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
ID: 41760391
FilesystemObject as @mx said is your friend


Dim fs As Object
Dim myfile As Object
Dim myfolder As Object
dim mystring as string
Set fs = CreateObject("Scripting.FileSystemObject")
mystring  = "SomeValidPathToAfolder"
Set myfolder = fs.GetFolder(mystring))
For Each myfile In myfolder.Files
    Msgbox myfile.Path
    msgbox myfile.Name
    msgbox myfile.datecreated
    msgbox Myfile.DateLastModified
Next myfile

replace the msgbox's with good recordset code and you are there.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 41760416
Of course, you would add rows into your table instead of msgbox
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 75
ID: 41760423
Nick already mentioned that "replace the msgbox's with good recordset code and you are there."

:-)
0
 

Author Closing Comment

by:Grizbear51
ID: 41761586
great code got it working perfectly thanks a lot
0
 
LVL 26

Expert Comment

by:Nick67
ID: 41761603
Excellent!
0
 
LVL 75
ID: 41761776
"as @mx said "
!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

749 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