ccondran08
Registered User.
- Local time
- Today, 18:44
- Joined
- Feb 27, 2014
- Messages
- 58
I have found the following code from a google search that will copy an attachment from a record to a file location. This serves the purpose of what i am trying to do, however I would like to make some modifications which i am struggling to solve. I would like to reference a query of the table instead of the table itself so i can put in some conditions in the query and then i would also like it to loop through the query so it will bulk save the records as it will only save one at a time at the moment. Thanks in advance.
On Error GoTo Err_SaveImage
Dim db As DAO.Database
Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2
Set db = CurrentDb
Set rsParent = Me.Recordset
rsParent.OpenRecordset
Set rsChild = rsParent.Fields("AttachmentTest").Value
rsChild.OpenRecordset
rsChild.Fields("FileData").SaveToFile ("C:\DB_Test")
Exit_SaveImage:
Set rsChild = Nothing
Set rsParent = Nothing
Exit Sub
Err_SaveImage:
If Err = 3839 Then
MsgBox ("File Already Exists in the Directory!")
Resume Next
Else
MsgBox "Some Other Error occured!", Err.Number, Err.Description
Resume Exit_SaveImage
End If
On Error GoTo Err_SaveImage
Dim db As DAO.Database
Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2
Set db = CurrentDb
Set rsParent = Me.Recordset
rsParent.OpenRecordset
Set rsChild = rsParent.Fields("AttachmentTest").Value
rsChild.OpenRecordset
rsChild.Fields("FileData").SaveToFile ("C:\DB_Test")
Exit_SaveImage:
Set rsChild = Nothing
Set rsParent = Nothing
Exit Sub
Err_SaveImage:
If Err = 3839 Then
MsgBox ("File Already Exists in the Directory!")
Resume Next
Else
MsgBox "Some Other Error occured!", Err.Number, Err.Description
Resume Exit_SaveImage
End If