Undo button

  • Thread starter Thread starter Mazza
  • Start date Start date
M

Mazza

Can anyone help please.
I have form with 2 subforms on it I have a button on the main form which is
disabled and enabled on the 'dirty' event, I have then put code behind the
button to undo the current entry, if required.
What I don't know is how do I ensure that the data entered if any in the sub
forms also undoes when the undo button is clicked.
Also what code would I use that allows you to click the undo button even if
there is nothing to undo without an error message popping up.
Thanks in advance to anyone who can help me with this.
Mazza T
 
Two parts to your question

a) There is no simple way to make an Undo button that applies to changes
entered in multiple forms (such as a form and subform.)

Accesss uses separate transactions in each form. Additionally, in a
typically form/subform connected via LinkMasterFields/LinkChildFields, the
subform gets reloaded each time the values in the main form change (by user
entry, or by moving record.)

It gets very convoluted to handle this by copying the records out to
temporary tables and making the changes there, particularly in a multi-user
environment like Access is.

b) Just test the Dirty property of the form before undoing it:

If Me.Dirty Then
Me.Undo
End If
 
Thanks Allen it's now a lot clearer to me


Allen Browne said:
Two parts to your question

a) There is no simple way to make an Undo button that applies to changes
entered in multiple forms (such as a form and subform.)

Accesss uses separate transactions in each form. Additionally, in a
typically form/subform connected via LinkMasterFields/LinkChildFields, the
subform gets reloaded each time the values in the main form change (by
user entry, or by moving record.)

It gets very convoluted to handle this by copying the records out to
temporary tables and making the changes there, particularly in a
multi-user environment like Access is.

b) Just test the Dirty property of the form before undoing it:

If Me.Dirty Then
Me.Undo
End If
 
Back
Top