Cannot update DAO Recordset

  • Thread starter Linq Adams via AccessMonster.com
  • Start date
L

Linq Adams via AccessMonster.com

Why won't this code update my recordset? I get Error 3027 "Cannot update.
Database or object is Read Only." Form is based on a query with 4 fields,
which in turn is based on a table with the same 4 fields. Both the form and
the query can be edited.

Microsotf DAO 3.6 Object Library is set in references

*******************Code******************
Dim rs As DAO.Recordset

Set db = CurrentDb

Set rs = db.OpenRecordset("MyQuery")

Do While Not rs.EOF
rs.Edit
rs!MyCheckBox = -1
rs.Update
rs.MoveNext
Loop

rs.Close
Set rs = Nothing

*****************End Code****************

Running Access 2003/SP2, Windows XP
 
L

Linq Adams via AccessMonster.com

From the original post:

"Both the form and the query can be edited."
 
B

bcap

You mentioned a form, but the code you posted is completely independent of
any form. Where did you say that the form which you so mysteriously
mentioned was bound to "MyQuery"? Hint: you didn't. Are you sure that it
is, or is the form a red herring?
 
B

boblarson

Linq:

Looks like you are updating all records in the query. So, why not just use
an update query? As for why it isn't updating, not sure.
--
Bob Larson

Free Tutorials and Samples at http://www.btabdevelopment.com

__________________________________
 
L

Linq Adams via AccessMonster.com

Actually, Bob, someone brought this to me asking why it wouldn't work. To be
honest, I've never used this kind of thing to do updates, but rather used an
update query, as you suggested. The actual code he brought me had conditional
statements and wasn't updating all records in the set. I simplified it to try
to isolate what was going wrong, and even in this simple form it still won't
update, which perplexes me, since the query itself, as well as the for based
on the query is updateable.
 

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