Solved

Alternatives to DoCmd.RunCommand acCmdUndo

Posted on 2014-10-27
4
279 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
[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
  • 2
4 Comments
 
LVL 85
ID: 40406309
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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40406312
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
ID: 40406340
Perfect!
0
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 40406372
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 …
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…

696 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