I have a search form that I want the user to close with a cancel button. If data is entered I don't want it saved. I have used the attached code, which works if there is data entered. But when no data is entered I get a run time error. How do I enable a user to close the form without saving data on the rare occasion that no data is entered?
Private Sub Cancel_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close acForm, Me.Name