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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dirty Property to Undo Last Action 2

Status
Not open for further replies.

cstuart79

Technical User
Nov 2, 2009
171
0
0
US
Trying to use a button "Cmd_Undo" to undo the last action performed in multiple subforms. any suggestions on what i am doing wrong with the following code? It does not generate any errors but it does not remove last action performed in subform.

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

 
Oops--meant:

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

 
How are ya cstuart79 . . .

Apparently you've never read VBA help on the [blue]Undo Method![/blue]. Otherwise you wouldn't be asking the question.
Microsoft VBA Undo Method said:
[blue]If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.[/blue]
See what I mean?

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
the undo command as shown in my sample code does not seem to affect any of the changes. clicking the command button doesn't seem to do anything at all. how can i have last action "undone"?
 
Undo is like "rollback" as opposed to "commit". It "undoes" a pending transaction rather than reversing a transaction already committed. If you have changed data in one subform and then move to another subform the data in the first subform is committed and cannot be "undone".

If you are looking for the equivalent of Excel/Word "Undo" then you'll have to code your own undo stack.

HTH

pjm
 
cstuart79 . . .

The Undo command needs to run in the respective code module of the mainform/subform where you wish the action to occur! For you this means your button and code [blue]needs to be on the subform[/blue] . . .

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
i would like to avoid putting buttons on every subform as this will take up alot of real estate--is it not possible to code for button on main form that will move focus to subform where last action took place?
 
cstuart79 . . .

The problem there is that once you move focus away from the subform [blue]the record will be automatically saved![/blue] We can't undo whats already comitted.

I'm thinking more along the lines of a [blue]HotKey![/blue] [pipe] ...

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Unfortunately, that is the crux of the issue.

Undo does not mean "undo the changes I have made to rows in the database". It means "undo the changes that I have not yet committed" - very different. And as TheAceMan1 says, once you have moved off a record the changes are committed and your chance to undo it is gone.

What can safely be undone in a multi-user environment? User A's changes to a record have been committed, User B has made subsequent changes, also committed, then User A decides he wants to undo his changes. What now?

Sadly I don't think you're going to have much luck with this, but I wish you well.

pjm

 
If you really want a multi-form undo then I'm afraid you have to deal with unbound forms.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top