?
Solved

Alternatives to DoCmd.RunCommand acCmdUndo

Posted on 2014-10-27
4
Medium Priority
?
296 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 2000 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
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…
Suggested Courses

762 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