cancel button for form

R

robin

How do you program a cancel button so that the form does not file the
information in the table?
 
J

Jason

Set the button's cancel property to True and then place the following code in
the button's _Click procedure:

Private Sub cmdCancel_Click()
If Me.Dirty Then
Me.Undo
End If
DoCmd.Close acForm, Me.Name

End Sub
 
W

Wayne Morgan

First, you have a Cancel button preprogrammed for you. The Esc key does this
job. Educate the user that pressing Esc once undoes the current control and
pressing Esc a second time undoes the current record.

That said, the code you need behind a button is

Me.Undo
 
R

robin

thanks, jason & wayne

Wayne Morgan said:
First, you have a Cancel button preprogrammed for you. The Esc key does this
job. Educate the user that pressing Esc once undoes the current control and
pressing Esc a second time undoes the current record.

That said, the code you need behind a button is

Me.Undo
 
Top