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

时间:2017-02-16 06:47:39

标签: access-vba ms-access-2003

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 个答案:

答案 0 :(得分:0)

你应该坚持常数 - 并为了可读性而重写一点:

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