Question:

Error 3020 for VB: Update of CancelUpdate without AddNew or Edit?

by  |  earlier

0 LIKES UnLike

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

 Tags:

   Report

1 ANSWERS


  1. Just a quick look at your code:

    Adding

    Case vbCancel:

      Cancel = True

      Me.Dirty = False  

    will roll back the changes and save the record as it was

    Hope that helps

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.