RE: Error 3020 for VB: Update of CancelUpdate without AddNew or Ed

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks, but Cancel is appropriate when you want to continue with the
updating, but not lose what you've already changed, but not save and move to
another record, (ie - cancel record change). I've seen it in many
applications, and used it in many applications, and would like it in my
application.

"Maverick" wrote:

My gut reaction: Why do you want YesNoCancel as opposed to YesNo? Either they
want to save the changes or they don't. Cancel isn't really a valid option.
What is the code supposed to do when cancelled versus saying no to saving? It
seems that cancel leaves your code in limbo with nothing to do.

"Nomij" wrote:

I am trying to create a form that pulls up a record from a drop down list. If
the data is modified, a msg box confirms the change, " Yes, No, Cancel".
Everything works except "cancel". When you come back to the form, I get Error
3020 as named above. I've included the code below. Does anyone have a
solustion to this? (Access 2003) Thanks for any help!

Private Sub Combo53_AfterUpdate()
'Find the record that matches the control.
On Error GoTo Err_CommandExit

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Customer Name] = '" & Me![Combo53] & "'"

If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Err_CommandExit:
Me![Combo53] = Me.Customer_Name
Me.Bookmark = Me.Bookmark
Exit Sub


End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Confirm changes with user
Dim intAnswer As Integer
intAnswer = MsgBox("The Customer Info has been modified. Do you want to
save your changes?", vbYesNoCancel)
Select Case intAnswer
Case vbYes
Cancel = no
Case vbNo
Me.Undo
Case vbCancel
Cancel = True
End Select
End Sub
.



Relevant Pages