I am trying to add a record to a recordset using VBA with the following code:
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim var As Variant
Set db = CurrentDb
Set rs = db.OpenRecordset("NextTaskCriteria")
For Each var In Me.lstSources.ItemsSelected
With rs
.AddNew
.Fields("Source") = CLng(Me.lstSources.Column(0, var))
.Fields("EmployeeID") = Me.SelectedEmployeeID
.Update
End With
Next
MsgBox "Updated successfully...", vbInformation
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
However, its stops on the first line with the error User-defined type not defined.
I am using an SQL backend, would there be different code to update or add to a recordset?