禁用默认MSGBOX [英] Disable default msgbox

查看:130
本文介绍了禁用默认MSGBOX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用从Access默认MSGBOX。这是我的code,

I want to disable the default msgbox from Access. This is my code,

Private Sub textRequiredDate_AfterUpdate()

DoCmd.SetWarnings False

If Not IsDate(textRequiredDate.Value) Then
MsgBox "Please enter a date"

Else

End If

If textRequiredDate.Value < textOrderDate.Value Then
MsgBox "Required date must be after Order Date"
textOrderDate.SetFocus
textRequiredDate.SetFocus
textRequiredDate.Value = ""

Else

End If

End Sub

当我写我的要求,我得到了默认的MS接入MSGBOX日期的信,我想将其更改为自己的消息框。

When I write letters on my date required I get the default MS access msgbox, I want to change it to my own message box.

推荐答案

您可以用Form_Error事件创建自定义的错误,例如这是一个有效性规则的错误:

You can create a custom error with the Form_Error event, for example this is for a Validation Rule error:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
      If DataErr = 2107 Then
         MsgBox "There was an error."
         Response = acDataErrContinue
      End If
End Sub

其他错误可能是:

Other errors might be:

Private Sub Form_Error (DataErr As Integer, Response As Integer)
  Const REQUIREDFIELD_VIOLATION = 3314
  Const INPUTMASK_VIOLATION = 2279
  Const DUPLICATEKEY_VIOLATION = 3022
  If DataErr = DUPLICATEKEY_VIOLATION Then
     MsgBox "There was a key violation!"
     Response = acDataErrContinue
  End If
End Sub

这篇关于禁用默认MSGBOX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆