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 not working in subform

Status
Not open for further replies.

Hinfer

Programmer
Sep 14, 2001
69
CA
I created a cancel button on a form with a subform. My main form (client info) and subform allows for edits, additions and deletions. My subform allows many entries (aliases).

If the user decides to cancel the changes he made to a record than he/she can press cancel to undo. I want it to undo changes in both sub form and form.

The following codes works if I have made changes(edits) to both main and subform but not subform alone. It also does not work if I have only inserted a new record(new alias). What is wrong with the code?

Thanks


DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDOFIELD, , A_MENU_VER20
[Forms]![tblClient Form Edit]![tblAlias subform].SetFocus
DoCmd.DoMenuItem A_FORMBAR, A_EDITMENU, A_UNDOFIELD, , A_MENU_VER20
If Me.NewRecord Then
If MsgBox("Are you sure you wish to cancel record", 36, " Continue?") = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close
End If
End If
DoCmd.Close A_FORM, "tblClient Form Edit"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top