Solved

Alternatives to DoCmd.RunCommand acCmdUndo

Posted on 2014-10-27
4
259 Views
Last Modified: 2014-10-27
The DoCmd.RunCommand acCmdUndo in Access only works on the current form or subform fields, and of course the subforms may have several records related to the main form.  Is there a way to “undo” or cancel changes made throughout the form and all subforms?  Or is this just an intensive coding process?

Thanks!
0
Comment
Question by:Coaster_brook_trout
  • 2
4 Comments
 
LVL 84
Comment Utility
Moving from a Parent form to a Subform will trigger a save on the Parent form, and once that's done you cannot undo those changes.

Moving from a Subform back to a Parent form will save the data on the Subform, and the same caveat applies - can't be undone via the RunCommand method.

You can "cascade delete" data by setting this up in Access's Relationships window. Right click on the join line (the line that connects the table in that view) - but be aware that doing this will delete ALL child records if a Parent record is deleted (which should happen anyway). In my view, cascade delete is not a good setting to implement, but everyone has different opinions on this.

Otherwise, you're left with coding the delete process yourself.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
One further option is to use Temporary tables that can be filled with data, and presented to the users on the forms. The user would then explicitly click a Save button, and you'd run code that would move the data back from the Temporary tables to the Live tables. This is also quite code intensive, but it's about the only way you can allows users the ability to save changes to multiple related tables in a bound Access application.
0
 

Author Closing Comment

by:Coaster_brook_trout
Comment Utility
Perfect!
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
I frequently use the temp table method mentioned by Scott, when working with subforms where users need the ability to cancel changes.  There are a couple of issues:

1.  Creating a couple of queries to populate the temp tables
2.  Creating a couple of more queries to update the source tables.
3.  In a multi-user environment, determining whether the source record was changed by someone else during the time you were editing data.  When I'm doing this type of thing in a multi-user environment, I include a LastModified field in my source tables.  I copy that field over into my temp table, and before I write my updates to the source table, I check to see whether the LastModified value in the source table is greater than in my temp table.  If not, I write my updates to the source table and set the last modified date/time to Now().  However, if the source record has been updated, then you have to decide how you want to handle the differences between your temp table data and the new source table data.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now