' --------------------------------------------------------------------- ' List Files and add to Recordset ' ' http://www.AccessLearningZone.com ' Link: http://www.599cd.com/tips/access/140726-listfiles/ ' Created by Alex Hedley ' Date Created: 26/07/2014 ' Date Updated: ##/##/#### ' ' Required Refs: Microsoft Scripting Runtime ' --------------------------------------------------------------------- Option Compare Database Sub ListFiles(mySourcePath) Dim Counter As Integer Set myObject = New Scripting.FileSystemObject Set mySource = myObject.GetFolder(mySourcePath) On Error Resume Next Dim db As Database Dim rs As Recordset Dim mysql As String Set db = CurrentDb mysql = "tblPictures" Set rs = db.OpenRecordset(mysql, dbOpenDynaset) For Each myFile In mySource.Files rs.AddNew rs![PicturePath] = myFile.Path rs![PictureName] = myFile.Name rs![PictureSize] = myFile.Size rs.Update Counter = Counter + 1 Next ' Clean up rs.Close db.Close Set rs = Nothing Set db = Nothing Set myObject = Nothing Set mySource = Nothing MsgBox "Listed " & Counter & " Files." End Sub