Share via

Access Tab Control - Undo Record Updates

Anonymous
2019-02-11T19:18:45+00:00

I have a form with a tab control. I'd like to add a "cancel" button to the form to undo any changes, and this works fine for changes made to the first page of the tab control. But if I change anything on the second page, these changes are not cancelled. The second page consists of individual controls, not on a subform. 

I have tried using VBA:

Private Sub cmdCancel_Click()

If Me.Dirty Then 

Me.Undo

End If

DoCmd.Close 

End Sub

I have also tried using the command button wizard to create the cancel button. Both options work for edits made to page 1, but not page 2. 

Is there something special I need to do to also cancel the updates on page 2 of the tab control?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2019-02-11T22:42:02+00:00

Your code works for me.

I created a form with a tab control, and bound a table to that form. I placed 3 controls on one tab page, and 3 on another (all of them bound to the table).

I entered data into all controls, and then clicked my button (which contained exactly the same code as yours). The form closed, and when I checked the table there were no new records in the table.

I did have an Autonumber field in my form, and that Autonumber was incremented, but that's not really important.

Are you sure you're not working with Subforms? The behavior you describe sounds just like what happens when you move from a main form to a subform (the main form saves immediately).

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2019-02-11T23:07:14+00:00

    Thanks for your reply! At least this explains why I can't find others having this issue when I search, ha!

    I just realized that this second form is a kind of subform, I guess. The data in it has a 1:1 relationship with that in the main table, but I guess that still means it's kind of a subform even though it's not what I typically think of as a subform. My best option may be to move the info from that table into the main table (it was there for a reason, but this is probably more important than that reason). 

    Thanks for nudging me in the right direction - I appreciate it!

    Was this answer helpful?

    0 comments No comments