close form without saving the record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am trying to create a bound form with a query, but I do
not want the record to be saved when the cursor moves to a
subform or when they close the form. I want to creat a
button for users to click on to save the record. I do not
care about the subform record. Is there a setting in the
form properties to prevent saving when closing form?

thanks

Pauli
 
There are so many ways a record can be saved! The only way to catch them all
is to use the BeforeUpdate event of the *form*. Cancel the event and undo
the form to prevent the save:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = True
Me.Undo
MsgBox "We discarded your edits."
End Sub

This event will run whenever the user does something that would cause the
record to save, such as moving focus to a subform, cycling past the last
control, closing the form, applying a filter, changing the sort order,
requerying the form, etc.
 
Back
Top