“否”选择将我带到错误的下一个msgbox输入

时间:2020-04-23 20:07:45

标签: ms-access msgbox

If vbYes = MsgBox("Do you have Federal Employee Health Benefits (FEHBB), such as Blue Cross Blue Shield?", vbYesNo + vbQuestion) Then
End If
If vbYes = MsgBox("Would you like to terminate/suspend your Federal Employee Health Benefits (FEHB) while on orders?", vbYesNo + vbQuestion) Then
    FEHBCancel = InputBox("Please initial here to cancel/suspend your FEHB.")
Else
NoFEHB = InputBox("Please initial here indicating that you do not have Federal Employee Health Benefits.")
End If

上面似乎一直运行着,但是我现在遇到的问题是当我问第一个msgbox“你有FEHB ...”时,如果我选择“ No”,我希望它继续进行到新的msgbox“请在此处初始指示您没有...”。如果答案是“是”,那么我想转到msgbox“您要终止”吗,另一个是/否。然后从那里开始,如果他们选择“否”,则可能是另一个框,他们不想终止。

1 个答案:

答案 0 :(得分:0)

下面是一些VBA代码,该代码显示了应如何进行。在执行此类操作时,通常有助于在纸上画出逻辑过程,并且在对If语句进行编码时,始终缩进每个嵌套级别以保持可读性。

Sub sMsg()
    Dim strTerminate As String, strPayFor As String, strNoFEHBB As String
    If vbYes = MsgBox("Do you have FEHBB?", vbYesNo) Then
        If vbYes = MsgBox("Do you want to terminate", vbYesNo) Then
            strTerminate=InputBox("Please initial to terminate")        
        Else    '   No they don't want to terminate
            strPayFor=InputBox("Please initial to pay")
        End If
    Else    ' do not have FEHBB
        strNoFEHBB = InputBox("Please initial here")
    End If
End Sub

此致

相关问题