Fix an Access Tab Control Cancel Button That Does Not Undo Changes
Question details
The user needs a Cancel button to discard edits made across an Access form's tabs.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A form has a tab control, with a subform on the second tab, and a VBA Cancel button that calls Me.Undo.
- Observed behavior
- Edits on the first tab are canceled, but changes associated with the second tab remain.
Open the form in Design View and check whether the second tab contains a subform control. Identify the control's name in its Property Sheet and determine whether edits are still unsaved when Cancel is clicked.
Undo unsaved edits in the form and subform separately
Use each form's Undo method for its own current, unsaved record.
A subform is a separate form even when its table has a one-to-one relationship with the main table. Moving focus to the subform can save the main form's record, and moving focus back to the main form can save the subform's record. Undo cannot reverse changes that have already been saved.
Open the main form in Design View, select the subform control on the second tab, and find its Name on the Property Sheet's Other tab. Use the control name, which may differ from the form object's name.
In the subform's Design View, add a Cancel button and set its On Click event to an event procedure. Use `If Me.Dirty Then Me.Undo` to discard unsaved changes to the subform's current record before leaving it.
Open the main form's Cancel button On Click event procedure and use `If Me.Dirty Then Me.Undo` to discard its current unsaved record. If the main record was saved when focus entered the subform, this action cannot restore its earlier values.
Switch to Form View, edit each tab, and click the relevant Cancel button before leaving the edited form. Reopen the records to verify which changes were discarded and which were saved.

Redesign the form for an all-or-nothing cancel
Use this approach when Cancel must discard edits across both tabs, including changes that Access would otherwise save while switching forms.
Use WPS Office for Everyday Office Files
WPS Office is a free, lightweight alternative for working with documents, spreadsheets, and presentations. Its familiar interface and Microsoft Office format compatibility make it easy to move everyday files, though it does not fix or replace Access forms and VBA.

Frequently Asked Questions
Why does Me.Undo not cancel edits on both tabs?
Me.Undo applies to the current unsaved record of the form running the code. If a tab contains a subform, that subform has its own record and Undo method.
Does a one-to-one relationship make the second form part of the main form?
No. A form displayed through a subform control remains a separate form, even if its underlying table has a one-to-one relationship with the main table.
Can Undo restore a record after Access saves it?
No. The form's Undo method discards pending edits to its current record; it does not reverse a save. For an all-or-nothing Cancel action, consider staged editing or another deliberate transaction design.
How can I find the subform control's name?
Open the main form in Design View, select the subform control, and check the Name property on the Property Sheet's Other tab. The control name may differ from the name of the form it displays.




