My ex-colleague built an Access database with many record sets and each of them has one to five pictures attached. The size of the database is now really big (about 2 GB) and it is really slow.
I managed instead of including the pictures in the database attachment, to just store the path and the name of the picture as strings in the columns and then recall them whenever I need to do that.
Now I have to export all of the existing images (about 3000 pictures) from the database to a folder after renaming them (with their description stored in another column in the DB, because now their names are like IMG_####, and I don't want to find AND rename them manually after exporting).
I've found something on the internet. But it just exports the attachment of the first record set only. How could I modify this to my need?
Dim strPath As String
Dim rs As DAO.Recordset
Dim rsPictures As Variant
strPath = Application.CurrentProject.Path
'????How to loop through all record set???
' Instantiate the parent recordset.
Set rs = CurrentDb.OpenRecordset("Assets")
' Instantiate the child recordset.
Set rsPictures = rs.Fields("Attachments").Value
' Loop through the attachments.
While Not rsPictures.EOF
'????How to rename the picture???
' Save current attachment to disk in the "My Documents" folder.
rsPictures.Fields("FileData").SaveToFile strPath & "\Attachment"
rsPictures.MoveNext
Wend
While Not rs.EOF
loop that you already have forrsPictures
for the mainrs
. – Gunrunning