Solved

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

Posted on 2015-02-05
5
170 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 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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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

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

Suggested Solutions

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

740 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