How to clear/update unbound controls when record cancelled

C

ChrisJ

Turn on the Form "KeyPreview" feature, and test for the
esc key in the form keypress or keydown event.
-----Original Message-----
This is best explained by a very simple example:

Private Sub UpdateTotals()
Total = Quantity x Price
End Sub

"Total" is an unbound text box. "Quantity" and "Price"
are bound text boxes. The UpdateTotals sub is called in
the AfterUpdate of Quantity (bound text box) and Price
(bound text box) as well as in Form_Current.
How can I revert the value of the unbound Total control
when a user causes the Undo event to fire by pressing
the "ESC" key without writing an OnKeypress event for
every control on the form?
The use of an Undo button allows me to call UpdateTotals
after Me.Undo. The problem occurs when a user presses
the "Esc" key; the values of the two bound controls
revert, but the unbound control does not.
The [Control]_Change event does not work because it does
not fire when the value of the control is set, only when
its Text property is set. The [Control].Undo event does
not work unless the particular control has the focus, so a
user could press ESC while another control has the focus,
again leaving the value of the unbound Total control
orphaned.
The Form_Undo does not work because it fires BEFORE the
values of the bound controls revert, not afterward.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top