I have a simple form that calls open a specific record and I would like to save a file from my computer to that records attachment field by using the dialog box. Can someone help me with the code for this? I found this code but i dont want to add a new row i want to add the file to an existing record that i have isolated using a query.
Code:
Dim dbs As DAO.databaseDim rst As DAO.RecordSet
' Ask the user for the file
Dim filepath AsString
filepath = SelectFile()
' Check that the user selected something
If Len(filepath)=0Then
Debug.Assert "No file selected!"
ExitSub
EndIf
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblAttach")
' Add a new row and an attachment
rst.AddNew
AddAttachment rst,"Files", filepath
rst.Update
' Close the recordset
rst.Close
Set rst =Nothing
Set dbs =Nothing