?
Solved

Dirty, undo, or sendkeys "{esc}{sec}"

Posted on 2015-02-05
5
Medium Priority
?
180 Views
Last Modified: 2015-02-05
Hi Experts,
I have a question about the code in a Cancel button on a form.  What is the best way to do in a Cancel Button.  should use: (what ever user(s) updated or enter anything on the form, if they click "Cancel" then anything the user just enter will not save and what ever data on the form before user update will still stay there)
a).  If me.dirty = true then
         me.undo
      end if
      docmd.close

b).  if me.dirty then
         me.undo
     end if
     docmd.close

c). me.undo
     docmd.close

d). sendkeys "{esc}{esc}"   -- this seems not working, may be I did it wrong
     docmd.close

Thanks,
0
Comment
Question by:urjudo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 668 total points
ID: 40591167
I'd use (a) or (b). That should undo any changes to the form where the code is running.
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 668 total points
ID: 40591169
just use

me.undo
docmd.close acform, me.name
0
 

Author Comment

by:urjudo
ID: 40591209
are a), b) and c) will do the same thing?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40591245
yes
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 664 total points
ID: 40591277
There may be nuances behind the scenes on the handling of these codes but in the end a, b, and c will do pretty much the same. This may just come down to user preference.  Me personally, I would do this:

If Me.Dirty Then Me.Undo
DoCmd.Close
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question