Good Afternoon,
I'm trying to loop through the values in a listbox (called "Attachments") and use those values to attach a file to a new record in a table. The attachments field in the table is called "Evidence". The below code will create a new record but not add the attachments.
Code:
Private Sub cmdImport_Click()
Dim dbs As Database
Dim rst As Recordset
Dim aFile
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("VRM Evidence")
rst.Edit
rst.AddNew
For Each aFile In Me.Attachments.ItemsSelected
rst.Fields("Evidence").LoadFromFile Me.Attachments.ItemData(aFile)
Next
rst.Update
rst.Close
Set rst = Nothing
Set dbs = Nothing
End Sub