I'm facing an error, please help, the debugger keep pointing at SaveToFile line, anyone know what's wrong with my code?
Private Sub Form_Timer()
Dim rst As DAO.Recordset2
Dim rsA As DAO.Recordset2
Dim fld As DAO.Field2
Dim db As DAO.Database
Set db = CurrentDb
If DCount("FileName", "Query1") > 0 Then
Set rst = db.OpenRecordset("Query1")
Set rsA = rst.Fields("Attachments").Value
If Not (rst.EOF And rst.BOF) Then
rst.MoveFirst
Do Until rst.EOF = True
rsA.Fields("FileData").SaveToFile "D:\" & rst.Fields("FileName").Value & rsA.Fields("FileType")
rst.Edit
rst!ExportedFlag = "Yes"
rst.Update
rst.MoveNext
Loop
Else
MsgBox "There are no new records in the database."
End If
MsgBox "Finished looping through records."
rst.Close
Set rst = Nothing
Set rsA = Nothing
Set fld = Nothing
Set db = Nothing
End If
My error message:
