I have a subform which has buttons on it to save the entered data or to clear the data and exit the form.
Save works fine, but a problem with the cancel button.
Code behind the cancel button is:
Private Sub CancelAssignment_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close acForm, “NewAssignment”, acSaveNo
End Sub
If I have made changes it works correctly, but if I just cancel without having made changes I get the message
Run-time error ‘2046’:
The command or action ‘Undo’ isn’t available now.
What extra code do I need to check if there has been a change before closing the form?
John