• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Cancelling a new record

I have a form to enter client names into a large client list that is used in different places throughout my database.  I want to have a submit button and a cancel button.  However, i basically built a form with one single textbox, and if you enter anything into the textbix, it starts a new record and enters the portion of the data.  So, How do I cancel this record?  If i have already entered some of the name, and want to cancel...how do use a "Cancel" button to erase that particular record?  Thanks for the help.
1 Solution
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Use the Undo method

      ' Abandon the Edit
      ' Note that record may not be dirty if user manually did an undo.
      If frm.Dirty = True Then
      End If

Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Ah I was using a form object variable there.  Change that to Me.Undo for it to work within the form.

The way I do something similar is to have the additions done in a working table.  This table is just like the big final table but without an autonumber.  Then if the user is happy with the record(s) there is a button on the form for the working table to append working table to final table and delete records in working table.  If the user is unhappy, there is another button which just deletes records in the work table (no append).

You can also use the working table idea if you are adding multiple records and want to set a default with effecting the big table.

Try to play with BeforeInsert event for your form, here you can cancel insertion of new record.
scrairAuthor Commented:
Thanks for all your help Jim
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now