Nicotto Town



【Access】elseifの使い方





Private Sub コマンド6_Click()

If Forms!narrow_form!チェック0 = True And Forms!narrow_form!チェック2 = False And Forms!narrow_form!チェック4 = False And Forms!narrow_form!チェック8 = False Then
DoCmd.OpenForm "order_applix"
DoCmd.Close acForm, "incomplete_end", acSaveNo
DoCmd.Close acForm, "order_user", acSaveNo
DoCmd.Close acForm, "order_importance", acSaveNo
DoCmd.Close acForm, "order_lapsed_day", acSaveNo
DoCmd.Close acForm, "narrow_form", acSaveNo

ElseIf Forms!narrow_form!チェック4 = True And Forms!narrow_form!チェック2 = False And Forms!narrow_form!チェック0 = False And Forms!narrow_form!チェック8 = False Then
DoCmd.OpenForm "order_importance"
DoCmd.Close acForm, "incomplete_end", acSaveNo
DoCmd.Close acForm, "order_applix", acSaveNo
DoCmd.Close acForm, "order_user", acSaveNo
DoCmd.Close acForm, "order_lapsed_day", acSaveNo
DoCmd.Close acForm, "narrow_form", acSaveNo

ElseIf Forms!narrow_form!チェック2 = True And Forms!narrow_form!チェック4 = False And Forms!narrow_form!チェック0 = False And Forms!narrow_form!チェック8 = False Then
DoCmd.OpenForm "order_user"
DoCmd.Close acForm, "incomplete_end", acSaveNo
DoCmd.Close acForm, "order_applix", acSaveNo
DoCmd.Close acForm, "order_importance", acSaveNo
DoCmd.Close acForm, "order_lapsed_day", acSaveNo
DoCmd.Close acForm, "narrow_form", acSaveNo

ElseIf Forms!narrow_form!チェック8 = True And Forms!narrow_form!チェック0 = False And Forms!narrow_form!チェック2 = False And Forms!narrow_form!チェック4 = False Then
DoCmd.OpenForm "order_lapsed_day"
DoCmd.Close acForm, "incomplete_end", acSaveNo
DoCmd.Close acForm, "order_applix", acSaveNo
DoCmd.Close acForm, "order_importance", acSaveNo
DoCmd.Close acForm, "order_user", acSaveNo
DoCmd.Close acForm, "narrow_form", acSaveNo

End If

End Sub


elseifの使い方。
1つのフォームに複数のチェックボックスがあり、特定のチェックボックスのみチェックされている場合の分岐。




Copyright © 2025 SMILE-LAB Co., Ltd. All Rights Reserved.