Full Version: Code for 'ESC' key
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
waratah
Hi all,
oes anyone have code for a button that will close a form and cancel all the data that was input? ie. the equivalent of pressing the ESCAPE key.
Thanks!
Alan_G
Hi
Welcome to Utter Access frown.gif
In the On Click event of your command button, try
Me.Undo
Docmd close acForm, Me.Name
HTH
Alan
waratah
Thanks for that.
ended up figuring out a way of doing it using Sendkeys in a macro, though I think your way is more efficient.
Cheers anyway frown.gif
Alan_G
No problem, glad you got it working frown.gif
Just as a pointer, I know from experience that Access can be very daunting particularly when you first start using it and that it is a very multi-learning environment (structure, naming conventions, relationships, SQL, VBA etc etc) but you would be well advised to start using Visual Basic for Applications (VBA) instead of macros. It's a powerful programming language that is far more flexible than macros, there's lots of things that aren't possible with macros and importantly you can trap and handle errors (amongst other things). You'll find lots of examples of VBA code both here at UA and on the web.
Good luck with your project.... frown.gif
HTH
Alan
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.