如何防止在尝试关闭表单时填充 Microsoft Access 错误消息?
How to prevent an Microsoft Access error message from populating when trying to close a form?
我在 Access 中有一个带有一堆下拉菜单框的表单。如果我从列表中选择一个值,然后改变主意并再次将其留空,单击关闭,我总是会收到此消息:
the data has been changed
Another User edited this record and saved the changes
before you attempted to save your changes
Re-edit the record.
我在后台有 3 个不同的宏 运行
交易类型
贷款异常评论
更新标志
我不认为那些宏会影响任何东西来给出那个错误。但是我可以写一些东西,以便它捕获此错误消息并忽略它并在我单击关闭时继续关闭吗?
主窗体VBA有这样的代码:
Private Sub Close_Click()
Me.FrmJobDetails.Form.Requery
Me.subform1.Form.Requery
If Me.FrmJobDetails.Form.Dirty = True Then 'what I tried adding
me.FrmJobDetails.Form.Dirty = False 'what I tried adding
End If
If Me.subform1.Form.Dirty = True Then 'what I tried adding
me.subform1.Form.Dirty = False 'what I tried adding
End If
DoCmd.SetWarnings (WarningsOff)
DoCmd.Save
entry
DoCmd.OpenQuery ("aqrySBORequestSiteDetail"), , acReadOnly
DoCmd.Close
DoCmd.SetWarnings (WarningsOn)
End Sub
在该代码中,注释 "what I tried adding" 是我认为可以防止出现该错误消息的内容。
有什么建议吗?
嗯...跳过它:
On Error Resume Next
在宏的顶部将跳过任何有错误的命令。
这不会解决问题,但会停止弹出错误。
我用它来处理 写入冲突 错误 (7787)。当存在写冲突时,第一个更改通过,第二个更改被丢弃。
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 7787 Then
Response = acDataErrContinue
On Error Resume Next
With Me.Recordset
.MovePrevious
.MoveNext
End With
On Error GoTo 0
End If
End Sub
我在 Access 中有一个带有一堆下拉菜单框的表单。如果我从列表中选择一个值,然后改变主意并再次将其留空,单击关闭,我总是会收到此消息:
the data has been changed
Another User edited this record and saved the changes
before you attempted to save your changes
Re-edit the record.
我在后台有 3 个不同的宏 运行
交易类型
贷款异常评论
更新标志
我不认为那些宏会影响任何东西来给出那个错误。但是我可以写一些东西,以便它捕获此错误消息并忽略它并在我单击关闭时继续关闭吗?
主窗体VBA有这样的代码:
Private Sub Close_Click()
Me.FrmJobDetails.Form.Requery
Me.subform1.Form.Requery
If Me.FrmJobDetails.Form.Dirty = True Then 'what I tried adding
me.FrmJobDetails.Form.Dirty = False 'what I tried adding
End If
If Me.subform1.Form.Dirty = True Then 'what I tried adding
me.subform1.Form.Dirty = False 'what I tried adding
End If
DoCmd.SetWarnings (WarningsOff)
DoCmd.Save
entry
DoCmd.OpenQuery ("aqrySBORequestSiteDetail"), , acReadOnly
DoCmd.Close
DoCmd.SetWarnings (WarningsOn)
End Sub
在该代码中,注释 "what I tried adding" 是我认为可以防止出现该错误消息的内容。
有什么建议吗?
嗯...跳过它:
On Error Resume Next
在宏的顶部将跳过任何有错误的命令。
这不会解决问题,但会停止弹出错误。
我用它来处理 写入冲突 错误 (7787)。当存在写冲突时,第一个更改通过,第二个更改被丢弃。
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 7787 Then
Response = acDataErrContinue
On Error Resume Next
With Me.Recordset
.MovePrevious
.MoveNext
End With
On Error GoTo 0
End If
End Sub