Solved

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

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 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