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

Need a clue for performing undo edits on subform

Status
Not open for further replies.

TrollBro

Technical User
Sep 4, 2004
98
US
Hello

Can anyone point me in the right direction on this? I have a form used to enter event data to a table. On the form I have a page with several tabs. on one of the tabs I have a subform to capture the names of attendees. If I load the form and edit a record on the form, I can use

If Me.Dirty = True Then
DoCmd.RunCommand acCmdUndo
endif

or a

If Me.Dirty = True Then
Me.Undo
endif

command to undo any chnges made during the editing as long as i never entered the subform. I need the undo function to return the main form AS WELL AS the subform data to its original state. Can that even be done? It seems the change in focus from main to subform prevents the undo from working on either, but if I stay out of the subform, the undo on the main form works fine for main form data undo. I think I'm missing the concept with subforms. I'd be greatful for any thoughts.

Thank you
 
How are ya TrollBro . . .
TrollBro said:
[blue]It seems the change in focus from main to subform prevents the undo ...[/blue]
TheAceMan1 said:
[blue]When you edit a record in the mainform (record in edit mode) and move the focus to the subform, [purple]the record is automatically saved![/purple] ... [blue]Undo[/blue] only works on records in edit mode, and since the mainform record was automatically saved, [blue]Undo fails![/blue][/blue]
The main idea involves the mainforms [blue]On Current[/blue] event. Here you save the full array of default field values to Public or Static variables, or save to an Array, before any editing is done. Then in your routine that performs the subform [blue]Undo[/blue], you Set focus to a field on the mainform and restore the saved default values. Then save the record! ... All is now fully [blue]UnDone![/blue]

[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]
 
Thanks AceMan1

After digging around a bit after my post and finding bits and pieces of info I think your idea sounds like the safest way to go - actually reminds me a bit of something I did years ago. The only heavy lifting and trick I'll have to figure out will stem from the fact that the subform could have any number (but less than a few dozen) records for every one main record. Luckily the subform records have only about 5 or 6 fields with one being a unique ID. Thanks for your thought - its what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top