Lost data changes upon Cancel

C

ctdak

When allowing the user to cancel/exit out of a data input form by hitting the
Escape button on the keyboard, any changes to the current record are lost.
Is there any way to prevent the changes from being lost/undone as the form is
being closed in this manner?
 
C

ctdak

You misunderstood me. I don't want the Escape key to be disabled. I want to
allow the user to close a form using the Escape key, but I don't want changes
to be lost to the current record when they do this.
ctdak
 
O

Ofer

I did, but from the example you were given change this
If KeyCode = vbKeyEscape Then
KeyCode = 0
End If

To
If KeyCode = vbKeyEscape Then
DoCmd.Close
End If
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
C

ctdak

Wonderful. I had never done anything with capturing user key actions, but
this makes sense and does what I need, with one exception. All changes to
the current record upon Escaping are now saved in the table - this is great!
However, if you're in a text box when hitting Escape and you made a change to
the data in that text box, then the control (Me!TextBoxControl) maintains the
old value even though the table has the new value. If the user hits Tab (to
move out of that control) and then Escape, the control in question then has
the new value and matches the table value.

Any idea why this is happening? It makes a difference to me because I am
assigning the value of Me!TextBoxControl to a global variable and it needs to
have the user's new value real-time.

ctdak
 
Top