当 ms 访问中的 MsgBox 函数在 vbYesno 中返回 -1 值时

Posted

技术标签:

【中文标题】当 ms 访问中的 MsgBox 函数在 vbYesno 中返回 -1 值时【英文标题】:When the MsgBox function in ms access returns -1 value in vbYesno 【发布时间】:2017-02-16 06:47:39 【问题描述】:
If [Due_date] < (Date - 1826) Then 
j = (MsgBox("This invoice is long overdue, isn't it. Is it correct?
     Do you want to save it?", vbYesNo, "Due date < 5 yrs from Today")) = 7 

If j = -1 Then DoCmd.GoToControl ("Due_date"): GoTo 9999

j 什么时候会有 -1 的值。 我试图到处寻找,却找不到。

【问题讨论】:

【参考方案1】:

您应该坚持使用常量 - 并为了可读性而稍微改写:

If [Due_date] < DateAdd("yyyy", -5, Date) Then 
    If MsgBox("This invoice is long overdue, isn't it. Is it correct? Do you want to save it?", vbQuestion + vbYesNo, "Due date < 5 yrs from Today") = vbNo Then
        DoCmd.GoToControl "Due_date"
    Else
        GoTo 9999
    End If
End If

【讨论】:

以上是关于当 ms 访问中的 MsgBox 函数在 vbYesno 中返回 -1 值时的主要内容,如果未能解决你的问题,请参考以下文章