Using code, how do I 'hit the escape key' through code when in the data add
mode?
In other words, when you are adding a new record and the record selector
changes from an arrow to a pencil, you can hit the escape key on the
keyboard to cancel adding that new record. How do I 'hit the escape key' by
using code?
Thanks,
Chris
Andrew Backer - 15 Jul 2005 21:23 GMT
Does SendKeys work in this situation?
Nelson - 15 Jul 2005 21:32 GMT
I thought of that also, but unfortunately it did not work. There must be a
way to do this! Does anyone know how?
> Does SendKeys work in this situation?
Rick Brandt - 15 Jul 2005 21:28 GMT
> Using code, how do I 'hit the escape key' through code when in the
> data add mode?
[quoted text clipped - 6 lines]
> Thanks,
> Chris
Me.Undo

Signature
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nelson - 15 Jul 2005 21:38 GMT
Me.Undo did not work either. Thanks for the try though. Any other
suggestions?
> > Using code, how do I 'hit the escape key' through code when in the
> > data add mode?
[quoted text clipped - 13 lines]
> to this message. Send instead to...
> RBrandt at Hunter dot com
Rick Brandt - 15 Jul 2005 21:47 GMT
> Me.Undo did not work either. Thanks for the try though. Any other
> suggestions?
I have used that quite a bit and it has always worked for me. What event
are you using it in? Are you sure there isn't something triggering a save
before the Undo line runs? Once the record is saved it is too late for
Undo.

Signature
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Wayne Morgan - 15 Jul 2005 21:36 GMT
Hitting the Esc key once will undo the current control. Hitting the Esc key
a second time will Undo the record. The equivalent in code is to tell either
the control or the form to Undo.
Me.ControlName.Undo
or
Me.Undo

Signature
Wayne Morgan
MS Access MVP
> Using code, how do I 'hit the escape key' through code when in the data
> add
[quoted text clipped - 8 lines]
> Thanks,
> Chris
John Vinson - 16 Jul 2005 02:11 GMT
>Using code, how do I 'hit the escape key' through code when in the data add
>mode?
[quoted text clipped - 6 lines]
>Thanks,
>Chris
SendKeys is buggy, unreliable, and AFAIK never worked in this context
anyway.
VBA code with Me.Undo will (as noted elsethread) cancel the current
record *if* it has not already been saved to disk. Note that if you
have a Form with a Subform, the mainform record is saved to disk the
moment you set focus to any control in the subform (and contrariwise,
the subform record will be saved if you set focus to the mainform).
John W. Vinson[MVP]