yogeshwarv
07-31-2010, 01:51 AM
Hi,
Whenever I try to enter any record in the access form, it saves the record by default. how to get rid of this? i do not want records to be saved until it is asked to save.
please help me.......
Yogeshwar Vats
HiTechCoach
08-01-2010, 09:41 PM
I recommend using the Form's Before Update event.
Example:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = False
' perform data validation
If IsNull(Me.CompanyName) Then
MsgBox "You must enter a Company Name.", vbCritical, "Data entry error..."
Cancel = True
End If
If Not Cancel Then
' passed the validation process
If Me.NewRecord Then
If MsgBox("Data will be saved, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Else
' run code for new record before saving
End If
Else
If MsgBox("Data will be modified, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
Cancel = True
Else
' run code before an existing record is saved
' example: update date last modified
End If
End If
End If
' if the save has been canceled or did not pass the validation , then ask to Undo changes
If Cancel Then
If MsgBox("Do you want to undo all changes?", vbYesNo, "Confirm") = vbYes Then
Me.Undo
End If
End If
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.