Results 1 to 2 of 2

Thread: undo button

  1. #1
    Join Date
    Jul 2002
    Posts
    4

    Unanswered: undo button

    I tried to add an undo button on a form. The button will undo the change in a text box named Contract. Here is the code. But it does not work.

    Public Sub CmdUndo_Click()
    Contract_BeforeUpdate
    End Sub

    Private Sub Contract_BeforeUpdate(Cancel As Integer)
    Me!Contract.Undo
    End Sub

    Any Suggestions?

  2. #2
    Join Date
    Jul 2002
    Posts
    67
    Try using this sample code in the click event of your undo button.



    Private Sub cmdUndo_Click()
    On Error GoTo errUndo

    DoCmd.RunCommand acCmdUndo
    DoCmd.RunCommand acCmdRecordsGoToFirst
    Exit Sub


    errUndo:
    If Err.Number = "2046" Then
    MsgBox "Their is nothing to undo.", vbInformation, "Unable To Undo"
    Exit Sub
    Else
    MsgBox "( " & Err.Number & " )" & " - " & Err.Description
    Exit Sub
    End If
    End Sub
    Don't do today, what can be done tomorrow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •