VBA msgBox - vbYes一直调用错误的子

时间:2015-08-27 13:59:46

标签: vba access-vba call msgbox

如果我点击是,VBA会继续使用Mandate函数吗?我做错了什么?

Public AutoDate As Date
Public NewDate As String

Public Sub GetDate()  ' DATUM BEPALEN
    AutoDate = Date - 1
    MsgBox (AutoDate), (vbYesNo), ("Datum")
    Dim Response As VbMsgBoxResult
        If Response = vbYes Then
            NewDate = AutoDate
            Call DeleteDate
        Else    ' No
            Call ManDate
        End If
End Sub

3 个答案:

答案 0 :(得分:2)

您还没有将MsgBox的结果分配给Response 不确定VbMsgBoxResult是否也是该实例中的有效数据类型。

尝试其中任何一种:

Public Sub GetDate()  ' DATUM BEPALEN

        Dim Response As Long

        AutoDate = Date - 1
        Response = MsgBox(AutoDate, vbYesNo, "Data")

        If Response = vbYes Then
            NewDate = AutoDate
            Call DeleteDate
        Else    ' No
            Call ManDate
        End If

    End Sub

update orders, (select @n:=max(delivery_number) from order_invoice) n 
   set delivery_number = @n:=@n+1 
   where delivery_number = 0 and invoice_number != 0;

答案 1 :(得分:1)

您需要检索响应作为MsgBox函数的返回:

Dim Response as Integer
Response= MsgBox( AutoDate, vbYesNo, "Datum")

现在你可以if-test Response来决定做什么。

答案 2 :(得分:1)

您需要一个变量来捕获响应......

Dim ans As Integer
ans = MsgBox("hello", vbYesNo, "Datum")
If ans = vbYes Then
   MsgBox "Yes"
Else
   MsgBox "No"
End If