|
以下是 版主 关于不按保存不保存的例子的 代码
Option Compare Database
Option Explicit
Dim blnAllowUpdate As Boolean '是否允许保存对记录的修改
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
blnAllowUpdate = True
DoCmd.RunCommand acCmdSaveRecord
blnAllowUpdate = False
Err_cmdSave_Click:
Call Form_Error(Err.Number, acDataErrContinue)
此句是运行错误处理过程。
Form_Error(DataErr As Integer, Response As Integer)
=================================================
请问一下:
过程参数:DataErr=Err.Number (这个参数【Err.Number 】应怎么找,主是要方法,我想用到一个更新前的过程,其中也代参数)
,Response=acDataErrContinue (这个参数【acDataErrContinue 】应怎么找,主是要方法,我想用到一个更新前的过程,其中也代参数)
==================================================
End Sub
Private Sub cmdUndo_Click()
Me.Undo
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If blnAllowUpdate = False Then Me.Undo
End Sub
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Response = acDataErrContinue
Select Case DataErr
Case 3022
MsgBox "您在不允许重复的字段中输入了重复的值,记录不能保存", vbCritical
Case 3314
MsgBox "必填项为空,记录不能保存", vbCritical
Case Else
Response = acDataErrDisplay
MsgBox DataErr & Chr(13) & Err.Description
End Select
End Sub
Private Sub 表1_子窗体_Enter()
Call cmdSave_Click
End Sub
|
|