Easy ADO database update question

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
 
B

Brendan Reynolds

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?
 
G

Guest

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?
 
B

Brendan Reynolds

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top