Easy ADO database update question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Why does this code for updating a single existing record in a linked table
not work please?

I see the updates in the recordset, but they don't get written back to the
table.

The recordcount is just to make sure I have a single record.

strSQL = "SELECT * FROM tblUnconfirmed WHERE lngInterco = " & lngInterco
Set rst1 = New ADODB.Recordset
With rst1
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open Source:=strSQL
.MoveFirst
.MoveLast
i = .RecordCount
.Edit
.Fields("dtmRefused").Value = Null
.Fields("dtmAccepted").Value = dtmAccepted
.Fields("txtContactB").Value = strContactB
.Fields("txtReason").Value = ""
.Fields("dtmBookMonth").Value = dtmBookMonth
.Update
End With
 
Unlike the DAO Recordset object, the ADO Recordset object does not have an
Edit method.

Are you not getting an error on the '.Edit' line?
 
No errors at all.
--
Carol


Brendan Reynolds said:
Unlike the DAO Recordset object, the ADO Recordset object does not have an
Edit method.

Are you not getting an error on the '.Edit' line?
 
You must have an 'On Error Resume Next' somewhere before the code you
posted. Otherwise, you'd be getting a 'Method or data member not found'
error message on the '.Edit' line. The solution is to delete the '.Edit'
line. With ADO, you just assign the values, there's no .Edit method.
 
Back
Top