PC Review


Reply
Thread Tools Rate Thread

Again:Recordset and update table "almost there"

 
 
=?Utf-8?B?UGV0ZXIgQWRlbWE=?=
Guest
Posts: n/a
 
      23rd Feb 2005
I finally foud out how DAO.recordset is working. Thanks to all the posted
items.
I am almost there, but the next error occurs:
Run-time error 3020: "Update or Cancelupdate without Addnew or Edit"
I want to go to record one, pick-up the value in field ID, go to the next
record and place this value in field ID.
And loop through the whole table.
I actually can see the value which has been picked-up, but Access cannot
update the table.
Here is the code:
Shell is the table/[ID] is the field

Private Sub Command0_Click()
Dim mydb As Database
Dim rst As DAO.Recordset
Dim waarde As String

Set mydb = CurrentDb()
Set rst = mydb.OpenRecordset("SELECT Shell.[ID]FROM shell;")

rst.MoveFirst
Do Until rst.EOF = True
waarde = rst![ID]
rst.MoveNext
rst![ID] = waarde
rst.Update
rst.MoveNext
Loop
Set rst = Nothing
Set mydb = Nothing
Exit_Command0_Click:
Exit Sub

Err_Command0_Click:

Exit Sub
Resume Exit_Command0_Click

End Sub
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQWRlbWE=?=
Guest
Posts: n/a
 
      23rd Feb 2005
Just saw a very new post were I could find my answer.
It works!!

"Peter Adema" wrote:

> I finally foud out how DAO.recordset is working. Thanks to all the posted
> items.
> I am almost there, but the next error occurs:
> Run-time error 3020: "Update or Cancelupdate without Addnew or Edit"
> I want to go to record one, pick-up the value in field ID, go to the next
> record and place this value in field ID.
> And loop through the whole table.
> I actually can see the value which has been picked-up, but Access cannot
> update the table.
> Here is the code:
> Shell is the table/[ID] is the field
>
> Private Sub Command0_Click()
> Dim mydb As Database
> Dim rst As DAO.Recordset
> Dim waarde As String
>
> Set mydb = CurrentDb()
> Set rst = mydb.OpenRecordset("SELECT Shell.[ID]FROM shell;")
>
> rst.MoveFirst
> Do Until rst.EOF = True
> waarde = rst![ID]
> rst.MoveNext
> rst![ID] = waarde
> rst.Update
> rst.MoveNext
> Loop
> Set rst = Nothing
> Set mydb = Nothing
> Exit_Command0_Click:
> Exit Sub
>
> Err_Command0_Click:
>
> Exit Sub
> Resume Exit_Command0_Click
>
> End Sub

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update recordset "Databse or object is Read only" error Alan Microsoft Access VBA Modules 3 12th Mar 2009 03:38 AM
"acessor flags" creating pivot table from recordset Wolfie Microsoft Excel Programming 1 12th Apr 2006 09:43 PM
"This recordset is not updatable" error in multi-table query MNF Microsoft Access ADP SQL Server 1 5th Mar 2004 05:26 AM
Copy recordset from an Access "make table" query Laurie Microsoft Excel Programming 1 5th Feb 2004 09:45 AM
Manual "Windows Update" produces "ActiveX/active scripting" error message even with "LOW" security level setting in "Trusted" Zone Ray2 Windows XP Help 1 14th Nov 2003 06:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:47 AM.