Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undo Last Action/Back Button 2

Status
Not open for further replies.

cstuart79

Technical User
Nov 2, 2009
171
US
is there a simple way to create an "undo last action/back button" in access which will simply restore to last state? i know there is a button called "undo record" but it doesn't seem to function as i want.
 
What about this (VBA code in a form) ?
ME.Undo

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
my "undo" button is on main form "CLIENTS". the code ME.Undo would go in on click event of button. however, i want the functionality to undo last action in various subforms. would this require incorporating "on focus" in some way to determine which subform should have last action undone? how should vba code be altered to do this?
 
would i just add the following code to the button and then add "dirty" code on each of the subforms and main form?

Sub Command379_Click()
Dim ctlC As Control
' For each control.
For Each ctlC in Me.Controls
If ctlC.ControlType = acTextBox Then
' Restore Old Value.
ctlC.Value = ctlC.OldValue
End If
Next ctlC
End Sub


Private Sub Form_Dirty(Cancel As Integer)
If Me.Dirty Then
Me.Command379.Enabled = True ' Enable button.
Else
Me.Command379.Enabled = False ' Disable button.
End If
End Sub
 

What is ctcC.OldValue ??

How about something like...
Code:
If Me.Dirty Then
    Me.Undo
End If

Randy
 
Tried your suggestion of code:

Private Sub Command379_Click()
If Me.Dirty Then
Me.Undo
End If
End Sub

It does not generate any errors but it does not remove last action performed in subform.
 
any suggestions on what i am doing wrong?

Private Sub Command379_Click()
If Me.Dirty Then
Me.Undo
End If
End Sub

It does not generate any errors but it does not remove last action performed in subform.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top