Lpurvis,
Thanks for your advice, but your solution also do not cover completely my question to undo changes to subrecords. Once changes made, how to undo and get the previous value of the record. Yes my subform and mainform is bounded, and I think it will stay like that.
Your solution is just a good example to view subrecords. My problem is also, why getting this navbuttons, can't I just undo changes made to subrecords via mainform? Via a SQL. The problem is also that I work with continous forms.
I have found some code on the net, the problem is that it undo's the changes made to mainform AND to the LAST record of the continous subform records. When there is 2 records, and you change 1st and 2nd, 1st record gets changed, 2nd one gets an undo, is there maybe a possibility to build this code for the other records too? Here under is the code with the commentary
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub ResetRecord_Click()
On Error Resume Next
Application.Echo (False)
Me!DAnalysis.SetFocus
DoCmd.RunCommand (acCmdUndo)
Me!ResetRecord.SetFocus
Application.Echo (True)
End Sub
The name of my button on the main form is "ResetRecord". When you click the ResetRecord button, I turn off Echo, so you don't see any changes happening. Then I set the focus to the subform...in my case, the subform is named DAnalysis. Then, I run the command acCmdUndo...which undoes the changes done to the form that has the focus...in this case, to my subform "DAnalysis". Finally, I reset focus to the "ResetRecord" button and turn the Echo back on.
Source:
http://www.xtremevbtalk.com/archive/index.php/t-72414.html posted by J-man.
==> names has to be changed to subform and button name, that is clear...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Maybe somebody can have a look at this code and extend it to all other records of the subform.
In attachment you find my file. When record is selected, press modify-> change it-> press 'Close' -> Changes must be undo, the code must be under that button.
That was a lot of typing.
Kind regards
Thank you
Ugurovic