ADODB recordset update refused - TechRepublic
Question
December 29, 2008 at 06:18 AM
terry.walters

ADODB recordset update refused

by terry.walters . Updated 17 years, 6 months ago

I have created a union query in string ‘SQLstr’ to select data by individual name and then provide column totals. This is sorted by person’s name (column 0), and to ensure the ‘totals’ row is at the bottom, I use name ‘zz’ on the union query. This is then put into a recordset called RS like this;

Set DB = CurrentProject.Connection
Set RS = New ADODB.Recordset
RS.Open SQLstr, DB, adOpenDynamic, adLockOptimistic.

I then want to tidy up the ‘zz’ name before sending the data to a MS Word table for output. When I use the following loop it finds the record but the fails with ‘Run time error, cannot update – database or object is read only’.

Do While Not RS.EOF
If RS.Fields(0) = “zz” Then
RS.Fields(0) = ” ”
RS.Update
End If
RS.MoveNext
Loop

Any suggestions as to why it fails, or how to update the ‘totals’ row in this dataset?

This discussion is locked

All Comments