Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with .recordset.delete??? 2

Status
Not open for further replies.

logo

Programmer
Aug 22, 2001
56
US
I am trying to delete a record from a table in ACCESS 2000 using the adodc.recordset.delete method. However, after the record has been deleted I cannot navigate through the rest of the table. Instead, I receive the error message "row handle referred to a deleted row or a row marked for deletetion."

I have tried evoking the .update and .updatebatch methods after evoking .delete, but this does not help.

Any ideas or suggestions would be greatly appreciated.

--BG
 
Thanks for your reply woyler,

if I refresh, then I receive the error msg "Operation was canceled." Any thoughts on this one?
 
Can you post your code from where you set the recordset to after you delete the record
 
I set the recordset at design time using its properties menu. Below is the code that I am using to delete the record.


Private Sub cmdDelete_Click()
Dim yesno As Integer
yesno = MsgBox("delete current record?", vbYesNo)
If yesno = 6 Then 'yes

---->here is where I delete!!
adodcAdmin.Recordset.Delete
adodcAdmin.Refresh
---->this generates the error msg "operation was canceled".

picEmpPicture.Picture = LoadPicture()
ClearFields
MsgBox "Record Deleted"
cmdNegotiate_Click (1)
End If
End Sub
 
I wrote some code to try to replicate your issue(I havent used a data control in a while, so bear with me). I created a adodb recordset and set the ADODC to it.

Set Adodc1.Recordset = rs

I deleted the current record:
Adodc1.Recordset.Delete
then moved to the next record with no errors.
Adodc1.Recordset.MoveLast

Unless I read you wrong, this is what you were having a problem with, right? One problem, may be the type of recordset you are using. try setting the cursor type to adOpenDynamic and the locking to adLockPessimistic.

My code above had no issues. If I misunderstood, let me know.
 
I still get the same problem...my data comes from a simple ACCESS 2000 table.

The .refresh method cleared up the row handle problem, but now I am getting the "operation was canceled" issue.

This is actually my first project using VB, so I am new to these issues. Every resource I can find provides sample code which looks exactly the same as what I have written. ??

By the way--thanks again for your help.

 
As far as I can tell the refresh method is working, however when I try to move/navigate to another record is where I have the problem.

The error # I receive is run-time error -2147217842 (80040e43)
 
I have tried .requery, it also generates the same error.
 
The error "row handle referred to a deleted row or a row marked for deletetion." means you tried to delete the same record twice. With your new error however, Check the data you are trying to delete. Look to see if there are any records in the table to delete. Is there only the one table?
 
There are PLENTY of records in the table :)...I thought of that one also.
 
I'm actually hung up now on what the "operation was canceled" Err. means (EXACTLY) and why I am evoking it when I try to navigate the recordset.
 
In your data control properties, are you using a dsn or a connectionstring? And which driver are you using? Jet x.x?
 
I am using a connectionstring AND Jet 4.0
 
After your "adodcAdmin.Recordset.Delete", try putting "adodcAdmin.Recordset.Update" instead of .Refresh and see if that works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top