One Main form and one subform (1 Viewer)


New member
Local time
Today, 00:23
Apr 29, 2022
Hello everyone,
I am just learning MS Access.
I created a Main form (Name: StaffUsers ) and a subform (Name: CalJOBS subform).
I put the Undo button on the Main Form. However when I click the Undo button on the main form, the entered data are cancelled on the Main form only
and the entered data are still in the subform. I would like to Undo all data in BOTH Main form AND subform.
The following is codes I write (not working so far). I have a form CalJOB subform, should I call it CalJOBS or [CalJOBS subform]?
Private Sub Cancel_Click()
With Me
Call .Undo
Call .CalJOBS.Form.Undo
End With
Call DoCmd.Close
End Sub

I appreciate any help.


Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:23
Feb 19, 2002
That's the way relational databases work and so that is how Access works. In order to add a child record to a table, its parent record must be added first. Access does this automatically for you when you move focus from a mainform to a subform and vice versa. Therefore, undo works ONLY on the current form's dirty record because that is the only record that has not been saved. It never affects any other records, especially those in a different table. Once a record is saved, it is not affected by undo.

If you want to get rid of both mainform and subform records, you must delete the main form record. If you have created relationships and specified cascade delete, then when you delete the mainform record, the child records will also be deleted. If you have not created relationships then, you MUST run a delete query to delete the child records followed by a delete of the main form record. If you delete the main form record without handling the child records, then you orphan them in database terms.
Last edited:


Super Moderator
Staff member
Local time
Today, 03:23
Jan 23, 2006
New member.
No familiarity with forum sections.
New to Access.
Any answer is/could be helpful.

Users who are viewing this thread

Top Bottom