This is my first time actually posting in a forum so let me know if I am using any bad practice here.
I am using access to organize iMessage data to format into a human-readable book. The database contains timestamp and attachment filename fields. The actual attachment file names contain said timestamp and filename values with some filler between. My goal is to parse through several thousand texts and import all attachments where applicable. See example below.
Database Example: https://i.stack.imgur.com/6rcgi.png
File Example: https://i.stack.imgur.com/0xvjy.png
I have the module written out as seen below and am getting "Error: "Run-time error '424': Object required" referencing line 27. Very helpful, Microsoft.
Option Compare Database
Function ImportAttach()
Dim db As DAO.Database
Dim rs As DAO.Recordset2
Dim rsT As DAO.Recordset2
Dim rsA As DAO.Recordset2
Dim fldT As DAO.Field2
Dim fldA As DAO.Field2
Dim strTimeStamp As String
Dim strFileName As String
Dim strPath As String
Dim strFile As String
Set db = CurrentDb
Set rs = db.OpenRecordset("iMessageDB")
Set fldT = rs("TimeStamp")
Set fldA = rs("Attachment")
strFilePath = "C:\Users\XPS\Documents\Projects\iMessage Book\attachments\"
rs.MoveFirst
Do Until rs.EOF
Set rsT = fldT.Value '<-- Error Here
Set rsA = fldA.Value
If IsNull(strFileName) Then
rs.MoveNext
Else
strFile = Dir(strPath & strTimeStamp & "*" & strFileName)
rs.Edit
rsA.AddNew
rsA("FileData").LoadFromFile strPathFileName
rsA.Update
End If
strFile = Dir
rsA.Close
rs.Update
rs.MoveNext
Loop
rs.Close
db.Close
Set fldT = Nothing
Set fldA = Nothing
Set rsT = Nothing
Set rsA = Nothing
Set rs = Nothing
Set db = Nothing
End Function
I have not found a good solution elsewhere, so I appreciate any help.