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"
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"