Undo change in subform

T

Terry

What is the best method for undoing changes in a subform from a command
button on a mainform? The subform is bound to a table on the many side of a
one-to-many with the main form.

Tried Me.subformname.Form.Undo

and

Me.subformname.Setfocus
DoCmd.RunCommand acCmdUndo

Regards
 
A

Allen Browne

That's not going to work well, Terry.

Access has to move the focus to the main form before it can make the command
button active and run its code. Before it can do that, it has to save the
record in the subform. That's exactly what you don't want.

Train your users to use the <Esc> key to undo the subform record.
Alternatively, get them to use the Undo button on the toolbar, or choose
Undo from the Edit menu.
 
T

Terry

Thanks Allen,
I realised after I posted why my previous attempts would not work, you're
right with pointing out the focus changes thus saving the record in the
subform. It's not too much of a problem as I have allowed edits and
deletions in the subform.
Regards
 
Top