Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting records on bound forms

Status
Not open for further replies.

rana

Technical User
Jul 5, 2000
20
0
0
US
I have a form "Requests" which contains a button on it that opens the form "New Request" both of which are bound to the table "Requests".  When "New Request" is opened, it automatically adds a new record to the table.  Then depending on the user, there is a button for "Save and Submit" and one for "Cancel" which uses the command CancelEvent.  However, if the user clicks on cancel, the record is still added to the table.  This results in lots of useless data being entered in the table.  Is there a way I can cancel without having the record automatically added or would I have to make the form unbound?
 
If you add a button to your form using the wizard, you can select &quot;Record Operations&quot; \ &quot;Undo Record&quot;, and it will put the code on the button for you.<br><br>Undo Record uses the DoMenuItem command. You can leave the button as is, or just copy the docmd line and put it on your own cancel button.<br><br>I usually always ask the user if the want to cancel adding the record before undoing it:<br><br>==========<br><br>Private Sub cmdCancel()<br>&nbsp;&nbsp;&nbsp;If MsgBox(&quot;Are you sure you wish to cancel adding this record?&quot;, 36, &quot; Continue?&quot;) = vbYes Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70<br>&nbsp;&nbsp;&nbsp;End If<br>End Sub<br> <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top