Cancel data entry of a record

ponneri

Registered User.
Local time
Today, 20:06
Joined
Jul 8, 2008
Messages
102
Hi.

How can I clear all the contents entered during data entry fields on a form, after say I enter 8 of the 15 fields on a form ?

What I mean is, I dont want that record to be entered. Access defaults to filling a record partly in the underlying table, as I am using a bound form.

Is there a VBA code to do it ??

My form contains mostly text boxes, drop down list, combo boxes and one check box too.

Please help.
 
Maybe a button with

Code:
Me.Undo

might do want you want,
 
You can use the forms Before_Update event.

This fires before the record is committed - so you can simply ask via a message box "Save Record?" If the response is no then
Cancel = True
Me.Undo
 
If you move to another forn while adding record, it will be saved unless you code BeforeUpdate of the form to not to allow partial data entered.
 
Thank you all very much.

I did try the me.undo attached to a cancel button on the form itself; but it does not work .

Prompts with a 'cannot undo' message.
( Is the me.undo meant for the last committed record to be rolled back - just for my knowledge)

BTW, I did not code Cancel = True before the me.undo in the code for the cancel button ?
 
Use forms before update event:

Private Sub BeforeUpdate(Cancel As Integer)
If Msgbox("Save record? ", vbYesNo) =vbNo then
Cancel=True
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom