0

I have a form where I ask the user to attach a file then press the Save button to save the attached file in the record along with the other entered data.

I managed to have the file picked but I need to save it in my table and I prefer to do it programmatically using VB.

The following code helped me with fetching the file and store it in a specific path on my computer but again that's not the case.

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("Attach").Value

rsChild.OpenRecordset
rsChild.Fields("FileData").SaveToFile ("C:\")

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

Maybe that can give you a head-start.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418

1 Answers1

0

In my endeavors doing Google searches I ran across this link (http://msdn.microsoft.com/en-us/library/office/ff835669.aspx) How to: Work With Attachments In DAO. Take a look at this and see if this will help, that is if you ain't been their done that already. I've been able to get allot help on MS web sites. Although I hate reading those stinking instructions. Steven

smith22554
  • 21
  • 1
  • 5