Open Form to new Record and don't save

JPR

Registered User.
Local time
Today, 11:51
Joined
Jan 23, 2009
Messages
219
Hello friends, back for some other useful help.
On a form I have placed a button to go to a new records: DoCmd.GoToRecord , , acNewRec.
It cold happen that users don't want to save this entry or accidentally erroneously clicked on the New Records Button.
Is there a way, you can recommend me to avoid this? Maybe some code that checks if no data has been entered, closed the forms without saving it. Thank you
 
the safest way is to use Transaction to your form.
 
Thank you. But honestly I have never heard about it.
 
Your question reminded me of a previous question on the forum which I answered here:-


Extract:-
The method sets the textbox default value. Now you can see the information and vet it without saving it to the table.

This method allows you to open a form, ready to enter a new record with some of the text boxes already filled with information. The user can then update the text. The action of making an update to the text saves the record, your changes, and the "default values".
 
Using transactions seems a bit of overkill. I agree with Gasman...and always use this
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  If Me.NewRecord Then
      If MsgBox("Would You Like To Save This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This Record ???") = vbNo Then
        Me.Undo
      End If
  End If
End Sub

Linq ;0)>
 
Thank you for your great help.
 

Users who are viewing this thread

Back
Top Bottom