我需要为一个变量搜索多个答案

时间:2018-12-12 18:55:59

标签: vba ms-access multidimensional-array

下面的代码试图根据“结果”的含义打开一个弹出屏幕。此命令按钮所在的报告具有“ PassFail”的多个行。我的目标是搜索每一行,并为不同的结果提供不同的弹出窗口。例如,如果任何“ PassFail”等于“ fail”或为空,则显示第一条弹出消息。如果所有“ PassFail”均等于“ Pass”,则第二条弹出消息。请帮忙!!!

Dim result As Variant
result = DLookup("PassFail", "dbo_TestDetail", "dbo_TestDetail.TDIndex" = " & Me!Index & ")

Dim Msg, Style, Title

If result = "Fail" Or Null Then

    Msg = "The test data for S/N " & Me!SN & " has nonconforming values. The TDS will not be approved."
    Style = vbCritical + vbDefaultButton2
    Title = "TDS Approval Denied"

ElseIf result = "Pass" Then
    Msg = "Are you sure you want to approve the test data for S/N " & Me!SN & "?"
    Style = vbYesNo + vbCritical + vbDefaultButton2
    Title = "TDS Approval"

End If

1 个答案:

答案 0 :(得分:0)

无法将任何内容与Null进行比较,当然不能简单地Or Null

If result = "Fail" Or IsNull(result) Then