Code for Esc

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone show me the way to write VBA code for the keystroke "Esc"? I
want to run this command when the form closes. Thanks...
 
See the SendKeys statement in VB Help.
Using SendKeys is kind of a klutzy way to do something. What is it you are
trying to accomplish? There may be a better way.
 
If someone has information in a particular textbox on my form and the record
is not saved or the user doesn't want the record saved, it seems the form
wants other information added or something done before the form is closed. I
get a message saying the record can't be saved. Hitting the escape key
deletes this info and lets the form close. I hope you understand what I'm
saying. Any help would be appreciated.
 
I agree with Klaatu: try to avoid SendKeys. Try this instead:

Me.Dirty = False

Barry
 
Yes, but that *usually* means your data is not saved?

Are you saying you need to code to close a form..but not save the data?

Just go

me.Undo ' this will undo all changes
docmd.Close
 
Me.Dirty = False will force an update.
To avoid an update, use
Me.Undo
That will prevent the update and set the values in the form back to what
they were before the close.
 

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

Back
Top