Code:
Run-TIme error '3021'
<Unknown error/message> HRESULT : &H800A0BCD
Code:
If Me.Photo.AttachmentCount <> 0 Then
Dim db As DAO.Database
Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2
Dim strFile As String
Set db = CurrentDb
Set rsParent = Me.Recordset
rsParent.OpenRecordset
[B][COLOR=Red]Set rsChild = rsParent.Fields("Photo").Value[/COLOR][/B]
rsChild.OpenRecordset
'File path to temp jpg file
strFile = CurrentProject.Path & "\Templates\tempProfile.jpg"
'Delete file if it exists
If Dir(strFile) <> "" Then
Kill strFile
End If
' then do your save
rsChild.Fields("FileData").SaveToFile (strFile)
Set rsChild = Nothing
Set rsParent = Nothing
End If
I only get that error if i replace an old image from the attachment, do a refresh. and then run the code "check if file exists on local drive then kill and replace"
If i replace an image in the record move to another record and then back to the old record and run the code i dont get the error prompt.....any ideas??