Cancelling a Text Box Edit

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

What is the best way to cancel an edit operation on data in a text box?
Manually, the user can hit the ESC key and the text box will resort back to
the data in it at the beginning of the edit. However, on certain text boxes
I would like to add a commit confirmation (i.e. YES/CANCEL). This probably
being best done in the BeforeUpdate event for the text box. However, what
is the best way to restore the original data in the case of a cancellation?
Is it best to copy the original data prior to editing? (If so, which event
is the best for placing the code to capture the data?) Or is there a
programmatic equivalent to the ESC key that will prevent the new data from
being committed?

Any ideas will be greatly appreciated!

Thanks!

Don
 
Don said:
What is the best way to cancel an edit operation on data in a text box?
Manually, the user can hit the ESC key and the text box will resort back to
the data in it at the beginning of the edit. However, on certain text boxes
I would like to add a commit confirmation (i.e. YES/CANCEL). This probably
being best done in the BeforeUpdate event for the text box. However, what
is the best way to restore the original data in the case of a cancellation?
Is it best to copy the original data prior to editing? (If so, which event
is the best for placing the code to capture the data?) Or is there a
programmatic equivalent to the ESC key that will prevent the new data from
being committed?


The equivalent is UnDo. A control's UnDo method is the same
as a user hitting Esc once. The Form's Undo method is the
same as a user hitting Esc twice.

I believe you want to use the BeforeUpdate event:

Me.thtextbox.Undo
Cancel = True
 
Marshall Barton said:
The equivalent is UnDo. A control's UnDo method is the same
as a user hitting Esc once. The Form's Undo method is the
same as a user hitting Esc twice.

I believe you want to use the BeforeUpdate event:

Me.thtextbox.Undo
Cancel = True


Marshall,

Perfect! Experimenting with the UnDo and Cancel have led to a lot of
improvements in the GUI!

Thanks!

Don
 
Back
Top