Solved

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

Posted on 2016-08-17
7
33 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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

757 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

22 Experts available now in Live!

Get 1:1 Help Now