undo form additions with sub-forms

  • Thread starter Thread starter Andrew
  • Start date Start date
A

Andrew

Hello,
Using Office XP, (Access 2002)
The scenario is a master/detail form.
Once the master has been updated And the detail (sub-form)
then the command:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,
acMenuVer70
Generated by the button wizard, no longer works?
The record changes are not undone...
Any suggestions?
Thanks in advance,
Andrew
 
Hello,
Using Office XP, (Access 2002)
The scenario is a master/detail form.
Once the master has been updated And the detail (sub-form)
then the command:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,
acMenuVer70
Generated by the button wizard, no longer works?
The record changes are not undone...
Any suggestions?

The problem is due to the way subforms have to work: typically a
Subform is bound to the "many" side table of a one to many
relationship. If (as should be the case) relational integrity is
enforced on this relationship, it is impossible to create a record on
the subform until the mainform record is actually saved to disk.

When you setfocus to a subform, the main form record is therefore
saved to disk. It's too late to undo it; in addition, as you move off
each subform record to a new subform record, it's also written to
disk. You can't "undo" it because it's no longer just on the form - it
has already been written out, and made available to any other user of
the database.

To "undo" it you will need to run a Delete query to delete the
mainform record; if cascade delete is set on the relationship, this
deletion will also delete the second table's records. If you don't
have cascade deletes set you will need TWO delete queries, one to
delete from the subform's recordsource, the other from the mainform.

If this isn't acceptable, you may want to consider having the Forms
bound to temporary tables rather than the "real" table; you'ld write
code to copy the updated records from temp to real at an appropriate
moment (perhaps a commmand button).
 
Back
Top