I'm extremely new at this, so apologize, but here's what I was intending. Using a front end/back end database setup. Front end user opens the database to create a record. Clicks a button that takes him or her to a new form where he or she can enter the data. All good and working well. I understand that at this point the new record is NOT created until the user actually clicks in a box or moves to a new record. I would like a cancel button here. I've learned that if the user created a record, it needs to be deleted at this time. If the user, hasn't done anything, then an undo is necessary as the record does not exist and a delete will cause an error...
Here is what I was hoping might work:
If IsNull(Me.Lname_Corrsp) Then
Me.Undo
ElseIf Not IsNull(Me.Lname_Corrsp) Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
End If
DoCmd.Close
DoCmd.OpenForm "opening menu", acNormal, , , acFormReadOnly
End Sub
It doesn't seem work though. I feel as though I'm close...but when I run this, the delete works perfectly if I enter a field value, but when a record has not been created (i.e. I do nothing but click the cancel button I create, it still tries to delete and I get an error....). Is the Null my problem? I've added this to an OnClick to a control button BTW.