Saigon- (name?)
You cannot force a save in the BeforeUpdate event because Access is still
waiting for you to decide whether to cancel the update or not. If it
allowed you to save, you would get in an infinite loop because BeforeUpdate
would try to fire again. Just let the code exit if the user replies Yes -
Access will immediately save the record. When the user replies No, you
should also do Cancel = True to halt the save.
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of saigonf7q5
Sent: Monday, August 19, 2013 10:52 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Error 2115, in Form_BeforeUpdate procedure
I have the procedure as shown here below. When the response is Yes, it
generated the Error 2115(The macro or function set to the BeforUpdate or
ValidationRule property for this field is preventing Microsoft Access from
saving the data in the field.)
Even though the error says ".preventing Access from saving." the changes
were still saved, however. I have also tried the "DoCmd.RunCommand
acCmdSaveRecord", it still produced the same error message. What or where
trigger the error??
Thanks
Phucon
Private Sub Form_BeforeUpdate(Cancel As Integer) On Error GoTo ErrorHandler
If Me.Dirty = True Then
If MsgBox("You have made changes to the data. Save changes?",
vbYesNo, "Information") = vbYes Then
Me.Dirty = False 'force the record to be saved explicitly.
'DoCmd.RunCommand acCmdSaveRecord
Else
Me.Undo
End If
End If
ExitProcedure:
Exit Sub
ErrorHandler:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_BeforeUpdate"
Resume ExitProcedure
End Sub
------------------------------------
Yahoo! Groups Links
| Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar