I have a code looping through a recordset and I'm trying to update the start date from a varible (JS) but its not updating... showing an error saying 'Update or UpdateCancel without addNew or edit'
I have put a .edit just after the ourRecordset![Start Date] = JS which is where its failing
Dim ourDatabase As Database
Dim ourRecordset As Recordset
Dim strSQL As String
Dim ActvJbNum As Long
Dim RecCnt As Long
Dim LpRecCnt As Long
Dim JS As Date
JS = Now()
ActvJbNum = Me.EntJobNum
strSQL = "SELECT tblRouting.[Job Number], tblRouting.[Start Date], tblRouting.OpDescription, tblRouting.[Op Seq], tblRouting.OpleadTm " & vbCrLf & _
"FROM tblRouting " & vbCrLf & _
"WHERE (tblRouting.[Job Number])= " & EntJobNum & vbCrLf & _
"ORDER BY tblRouting.[Op Seq] ASC;"
Set ourDatabase = CurrentDb
Set ourRecordset = ourDatabase.OpenRecordset(strSQL)
With ourRecordset
Do Until ourRecordset.EOF
RecCnt = ourRecordset.RecordCount
LpRecCnt = LpRecCnt + 1
ourRecordset![Start Date] = JS
ourRecordset.Edit
MsgBox ourRecordset![Start Date] & vbNewLine & ourRecordset![Op Seq] & vbNewLine & LpRecCnt
ourRecordset.MoveNext
Loop
End With
any idea why it's not updating the start date?
ourRecordset![Start Date] = JS<-- What are you trying to do here? Why are you trying to write-back to a (read-only) ADODB Recordset object? Are you trying to update values in your database table? If so then you need to execute an explicitUPDATEstatement.