Open Form to new Record and don't save

JPR

Registered User.
Local time
Today, 14:32
Joined
Jan 23, 2009
Messages
223
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.
 
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