Problem with undo command on form that contains a subform

bdg4820

New member
Local time
Today, 20:04
Joined
Dec 30, 2004
Messages
5
I have a main form, on the footer of the form I place the famous "Undo" button. So, in case people want to reconsider and undo their typing, a user can press this button.

My question, is it possible that this undo button also does it's job on a subform that is positionned on the main form. Currently This does not seem to work. Whenever a user changes something on the subform and presses the "Undo button" nothing happens on the subform. Only the things that were changed on the main form are undone.

I 'm currently using the following code associated with the click event on the undo button:
Docmd.RunCommand acCmdUndo
Thanks for the help in advance !!
 
Place another Undo button "in" the subform.
 
Well, placing a second "undo" button is indeed an option, but if it possible I would prefer to have only one "Undo button" since for the user the form is just one form and it looks quite strange to have two undo buttons. However, thanks for the suggestion.
 
Hi,

you may have to create a group of complex VBA code in your forms to get the "Undo" you need.

The record will be updated automatically when the focus move to another record in table, so if the subform is a continuous form or a datasheet, the above Undo code will not be able to work, even though you place another Undo button in the subform.

regards
 
When you move focus from the main form to a subform, Access autmatically saves the main form record. When you move focus from the subform back to the mainform, Access automatically saves the subform record. Therefore, a button on the mainform cannot "undo" changes to the subform record. You would need to implement this via VBA. For starters, you would need to save the before image of the subform record just in case you needed to undo the previous change. You would need to determine if the record was added/changed/ or deleted in order to properly recover it.
 
ok thanks, I understand the way to do it, no the question is writinge the VB code to do it :-)
 

Users who are viewing this thread

Back
Top Bottom