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

Cancel Subform changes 1

Status
Not open for further replies.

Devija

Programmer
Feb 3, 2002
5
US
I have a form which contains a subform. The subform is set to continuous forms. On the main form I have designed a navigation bar with buttons for add, edit, delete, etc. When the edit button is clicked, the fields in the form become editable including the subform and the only buttons on the navigation bar available are ok and cancel. The problem I have is that when changes are made in the subform such as adding new items or changing existing items, the cancel button on the main form does not undo those changes. It works great for anything on the main form but all changes in the subform are done. How can I make the cancel button undo all changes including those made to the subform.

Thanks or any help you can offer.
 
Try this in whatever event you want to control the undo
Me.MySubformName.Form.Undo Life's a journey enjoy the ride...
 
Thanks Jazz but that was the my original thought. It doesn't work. I think it would work if you were still in the subform on the record you just changed but in this case the subform is made of continuous forms and as soon as you move from one record in the subform to the next that change is automatically save to the underlying table so when you click on the cancel button on the main form your changes to the main form are thrown out but you have already committed the changes to the table for the subform so those don't change back.
I am wondering if there is a way that when someone clicks the edit button on the main form you can save the recordset of the current subform and then no matter what changes are made if, in the end, the user decides to cancel all changes when they click the cancel button on the main form the copy of the original recordset could be restored??

Any ideas would be great.

Thanks again
 
OK try this on your main form create an unbound textfield set its properties as visible=No and make the default value = to the current record of the subform. Now when you click cancel or whatever reference the record on the subform based on the value in the unbound text field on the mainform now you can reference the correct record on the subform and code it to do the undo.

When I get some free time *probably after the holiday* I will do the code and see if I get you working.

I hope I made this clear? Life's a journey enjoy the ride...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top