Best way to Cancel?

  • Thread starter Thread starter GaryS
  • Start date Start date
G

GaryS

The situation:

The active Form is one that was opened in Add mode.

The user begins to fill it out, but, at some point,
decides he wants to cancel . . . meaning close the form
and don't update any records.

I can provide a Cancel button, but what are the OnClick
actions necessary to inhibit the updates?
 
The user can Cancel by hitting the Esc key twice. The first one will cancel the current
field and the second one will cancel all of them.

To do this in the OnClick event of a button, canceling all of the changes on the form,

Me.Undo

You can also add something similar to this to the BeforeUpate event of the form.

If MsgBox("Save Changes?", vbYesNo + vbQuestion) = vbNo Then
Cancel = True
If MsgBox("Cancel Changes?", vbYesNo + vbQuestion = vbYes Then
Me.Undo
End If
End If
 
Thanks, Wayne, I'll use one of them!

-----Original Message-----
The user can Cancel by hitting the Esc key twice. The
first one will cancel the current
field and the second one will cancel all of them.

To do this in the OnClick event of a button, canceling
all of the changes on the form,
 
Back
Top