I have a table where there is a \"Photo\" text field with the name of the file. I also have the actual files in a separate folder. I want to attach those files to the databa
This helped me:
Originaly posted by HiTechCoach on http://www.access-programmers.co.uk/forums/showthread.php?t=169056
On Error GoTo Err_AddImage
Dim db As DAO.Database
Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2
Set db = CurrentDb
Set rsParent = Me.Recordset
rsParent.Edit
Set rsChild = rsParent.Fields("AttachmentTest").Value
rsChild.AddNew
rsChild.Fields("FileData").LoadFromFile ("c:\Sunset.jpg")
rsChild.Update
rsParent.Update
Exit_AddImage:
Set rsChild = Nothing
Set rsParent = Nothing
Exit Sub
Err_AddImage:
If Err = 3820 Then
MsgBox ("File already part of the multi-valued field!")
Resume Next
Else
MsgBox "Some Other Error occured!", Err.Number, Err.Description
Resume Exit_AddImage
End If