关闭“此表单上指定的记录源不存在”警告

时间:2019-06-24 07:56:59

标签: vba ms-access

如何关闭/禁用“此表单上指定的记录源不存在”警告消息?我创建了使用子窗体的GUI,但是在处理过程中生成了这些窗体的资源表。因此,这意味着打开数据库后GUI没有任何资源,并显示错误“此表单上指定的记录源不存在”。如何关闭/禁用它?我尝试添加DoCmd.SetWarnings False 但这对错误消息没有影响。

3 个答案:

答案 0 :(得分:2)

您可以将 RecordSource 留空或为其分配一些(空)虚拟记录。

RecordSource 设置为其实际值时,子窗体将自动重新查询。

答案 1 :(得分:1)

您需要查看Application.DisplayAlerts

Sub Example()
'do stuff

Application.DisplayAlerts = False
'Code that fires the warning message
Application.DisplayAlerts = True

'do stuff
End Sub

答案 2 :(得分:0)

除了禁用警报,您还可以向该表单/子表单分配一些不相关的表。

另一种解决方案-如果您有这样的错误号(我想是7874),则仅禁用此确切错误:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
  If DataErr = 7874 Then
    Response = acDataErrContinue
  Else
    Response = acDataErrDisplay
  End If
End Sub