Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancel Button won't undo changes in form AND subform

Status
Not open for further replies.

Hinfer

Programmer
Sep 14, 2001
69
CA
I have a form to enter client information. There is also a subform in the client information form.

I have created an edit button to take me to the client I want to edit. I have a cancel button to get out of the form without changing the information.

I used this code:

DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDOFIELD, , A_MENU_VER20
[Forms]![tblClient Form Edit]![Child30].SetFocus
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDOFIELD, , A_MENU_VER20
DoCmd.Close A_FORM, "tblClient Form Edit"

If I make changes to the main and sub the cancel button will undo the changes in all cases EXCEPT:

IF there is an empty field such as alias middle name that was not previosly filled out and I decide to fill it. That is the only thing field I changed. If I click cancel it will not undo the changes. It will add it in. Wierd!?! Can some help me debug this?

Thanks

 
straight from access help

The following example shows how you can use the Undo method within a control's Change event procedure to force a field named LastName to reset to its original value, if it changed.

Private Sub LastName_Change()
Me!LastName.Undo
End Sub

The next example uses the Undo method to reset all changes to a form before the form is updated.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.Undo
End Sub
 
Braindead2:

It will undo the main form but not the sub. I have stuck to my original code but thanks anyways.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top