Solved

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

Posted on 2015-02-05
5
150 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
5 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 167 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 167 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 119

Expert Comment

by:Rey Obrero
ID: 40591245
yes
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 166 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now