You have a folder full of images that you want to add to a database.
Create a Table called tblPictures with the following schema:
FieldName
DataType
PictureID
Autonumber
PicturePath
Text
PictureName
Text
PictureSize
Integer
Now you can create a Module in Access and add the following code.
Just call the Function passing in your folder.
ListFiles("D:\Folder\")
Option Compare Database
' Add Ref to Microsoft Scripting Runtime
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