How do I "Escape" data add mode?

N

Nelson

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
 
R

Rick Brandt

Nelson said:
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

Me.Undo
 
N

Nelson

I thought of that also, but unfortunately it did not work. There must be a
way to do this! Does anyone know how?
 
W

Wayne Morgan

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
 
R

Rick Brandt

Nelson said:
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.
 
J

John Vinson

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

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]
 

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