By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,153 Members | 2,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,153 IT Pros & Developers. It's quick & easy.

Method 'CancelUpdate' of object' _Recordset' failed

P: 4
I have encountered a problem which I'm still trying to fix. I'm ADO recordset to communicate with front end (form with textboxes) and main access table. It is as follows;

Setup ado recordset

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)  
  2.     Set rst = CreateObject("ADODB.Recordset")
  3.  
  4.     With rst
  5.       .ActiveConnection = CurrentProject.AccessConnection
  6.       .Source = "SELECT * FROM MapIndex"
  7.       .LockType = 3 'adLockOptimistic
  8.       .CursorType = 1 'adOpenKeyset
  9.       '.CursorLocation = 3 ' adUseClient
  10.       .Open
  11.     End With
  12.  
  13.     Set Me.Recordset = rst
  14. End Sub
  15.  
  16. 'Function to add record and save record
  17. Private Sub cmdAddRecord_Click()
  18.  
  19. If cmdAddRecord.Caption = "Add Record" Then
  20.    UnlockRecords
  21.    rst.AddNew
  22.    GivenName.SetFocus
  23. ElseIf cmdAddRecord.Caption = "Save Record" Then
  24.     rst.Update
  25.     LockRecords
  26. End If
  27. End Sub
  28.  
  29. Private Sub cmdEditRecord_Click()
  30.         If cmdEditRecord.Caption = "Cancel" Then
  31.              rst.CancelUpdate
  32.              LockRecords
  33.         End if
  34.  
  35. End Sub
The problem is when I do a rst.CancelUpdate with text written in any textbox it throws a error saying "Multiple-step operation generated errors. Check each status value" then after it shows #Deleted in all the controls. When no text is entered in any field and then rst.CancelUpdate works fine.

Can anyone help as I've been stuck with this error for a few days now. i've already passed the time to hand in database for testing. Thanks heaps.
Dec 5 '06 #1
Share this Question
Share on Google+
7 Replies


NeoPa
Expert Mod 15k+
P: 31,616
I may be wrong here, but I don't think you want to create a separate recordset and then add it to your form.
You should define a recordset for your form and access that from your code rather than vice-versa.
Dec 5 '06 #2

P: 4
I may be wrong here, but I don't think you want to create a separate recordset and then add it to your form.
You should define a recordset for your form and access that from your code rather than vice-versa.
Not such want you mean though. I have setup an ADO connection & recordset which I make the form's recordset equal to when the form is opened up. Please explain the vice versa way.
Dec 5 '06 #3

P: 4
Well it seems you guys dont understand my problem..will find solution elsewhere so much for discussing
Dec 6 '06 #4

NeoPa
Expert Mod 15k+
P: 31,616
Not such want you mean though. I have setup an ADO connection & recordset which I make the form's recordset equal to when the form is opened up. Please explain the vice versa way.
The Vice-versa is what you're doing.
You should (I think) be setting the recordsource then accessing the recordset as already set rather than setting your own one.
Is that clear?
Dec 6 '06 #5

NeoPa
Expert Mod 15k+
P: 31,616
Well it seems you guys dont understand my problem..will find solution elsewhere so much for discussing
???
I do find you difficult to understand but it is, of course, your prerogative to search elsewhere for answers.
Good luck and best wishes.
Dec 6 '06 #6

P: 4
Neopa

I managed to solve this problem myself by doing extra coding and not by what you suggested..tried it but did not solve problem. Thanks anyway. yep..its better when you can solve it yourself .
Dec 6 '06 #7

NeoPa
Expert Mod 15k+
P: 31,616
NeoPa

I managed to solve this problem myself by doing extra coding and not by what you suggested..tried it but did not solve problem. Thanks anyway. yep..its better when you can solve it yourself .
You're absolutely right. It is much better.
However, if you got that working then I have some learning to do (I was afraid of that).
Would you mind posting your solution in here so that other members and searchers can see your answer. That would be very helpful. I think I also need to look at it and learn when you do.
Well done.
Dec 6 '06 #8

Post your reply

Sign in to post your reply or Sign up for a free account.