rangersedge
Registered User.
- Local time
- , 20:20
- Joined
- Jun 13, 2014
- Messages
- 82
Ok. So I have learned my lesson on saving images into an Access DB. Now I'm using VBA (another good learning experince) to save the images back to a folder. I have a code working that will save the images but I need it to also rename the images after saving.
The section "MyFile = OldFile" needs to reference the rsChild Attachment file name...
The section "MyFile = OldFile" needs to reference the rsChild Attachment file name...
Private Sub Command859_Click()
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("Attachments").Value
With rsChild
.MoveFirst
Do While Not .EOF
rsChild.OpenRecordset
rsChild.Fields("FileData").SaveToFile ("V:\Lego\MediaDB\Images")
Exit_SaveImage:
.MoveNext
Loop
.Close
End With
MyPath = "V:\Lego\MediaDB\Images\"
MyFile = OldFile
NewName = Me.Title
Name MyPath & MyFile As MyPath & NewName
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
End Sub