Edit, Delete, Update ... Error :-(

S

Stephen

Hello People,

Using MS Access 2003 VBA I get the error 3020 Update or CancelUpdate
without AddNew or Edit when I run through the following code. Can
anyone help suggest anything to try? Thanks.

On Error GoTo delete_failed

Dim RS_DEL As DAO.Recordset

Dim DB As DAO.Database

Set DB = CurrentDb

' Delete Row in Nodes_T table

Set RS_DEL = DB.OpenRecordset("SELECT * FROM Nodes_T WHERE [Record_ID]
=" & Me.Record_ID, dbOpenDynaset, dbSeeChanges)

If RS_DEL.RecordCount = 1 Then

' If found record with correct record ID, DELETE IT

RS_DEL.Edit
RS_DEL.Delete
RS_DEL.Update

RS_DEL.Close
DB.Close
Set RS_DEL = Nothing

End if
 
T

Terry Kreft

Your code should be something like

Set DB = CurrentDb

' Delete Row in Nodes_T table

Set RS_DEL = DB.OpenRecordset("SELECT * FROM Nodes_T " _
& "WHERE [Record_ID]=" & Me.Record_ID, _
dbOpenDynaset, dbSeeChanges)

If RS_DEL.RecordCount = 1 Then
RS_DEL.Delete
End if
RS_DEL.Close
DB.Close
Set RS_DEL = Nothing

But wouldn't it be easier to just

Set DB = CurrentDb
DB.Execute "DELETE * FROM Nodes_T " _
& "WHERE [Record_ID] =" & Me.Record_ID
 

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