Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to replicate Escape key with VBA

Status
Not open for further replies.

lorirobn

MIS
Mar 15, 2005
450
US
Hi,

I have a subform, which is a continuous form. If I start to enter data on the 'addnew' line, then press the Escape key, this erases the data I have just entered.

I would like to replicate this action in my VBA code. If a user attempts to add a duplicate, I give a message, asking if they would still like to add the record. If they enter 'no', I would like to wipe out the data they have started to enter. Currently, the only code I have for 'no' is 'cancel=true'. I tried to add 'me.undo' but this didn't erase the data.

Any suggestions?

Many thanks, in advance.
 
Me.Undo

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,
I had tried me.undo, but it only undoes data in the last field entered, and I'd like to undo data in the rest of the line as well. Escape does that, and I'd like to do that as well.
thanks.
 
What about using Sendkeys in VBA?

Code:
sendkeys("{ESC}")

Check out the VBA help for more info on sendkeys.

A,
 
Thanks, Stuck. SendKeys is a great statement to know about, and it did the trick perfectly!

Thanks again. :)
 
Hi,

I recommend using SendKeys very sparingly and very carefully. It can be quite a pain in the back side, espescially when debugging/troubleshooting!

-----------
Regards,
Zack Barresse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top