samedi 12 décembre 2020

Complex IF statement with comboBoxes

I have a project that I am working on where I am wanting to pull selected values from two comboboxes and based on given data reflect in a blank label the items would reflect an yes or no. For example, I want to define if a given failure is controllable or not. Data coming from the combobox1 would state "Customer" Or "Field" and combobox2 would state "Accessory Failure" then the label would display "No". Or Data coming from the combobox1 would state "outbound" Or "process" and combobox2 would state "Accessory Failure" then the label would display "yes". I have included my code that seems to partial work. I am not sure where it is faulting at as I am too close to the forest to see the trees.

Private Sub combxBouncCat_Click()
Dim x As Integer
Dim Catrgory As String
Dim Reason As String

x = combxBouncCat.ListIndex

Select Case x
    Case Is = 0
        combxBouncReason.RowSource = "Customer"
    Case Is = 1
        combxBouncReason.RowSource = "Field"
    Case Is = 2
        combxBouncReason.RowSource = "Inbound"
    Case Is = 3
        combxBouncReason.RowSource = "Outbound"
    Case Is = 4
        combxBouncReason.RowSource = "Parts"
    Case Is = 5
        combxBouncReason.RowSource = "Process"
    Case Is = 6
        combxBouncReason.RowSource = "QA"
    Case Is = 7
        combxBouncReason.RowSource = "Repair_Tech"
    Case Is = 8
        combxBouncReason.RowSource = "Support_Tech"
    Case Is = 9
        combxBouncReason.RowSource = "Undetermine"
End Select

Category = combxBouncCat.Value
Reason = combxBouncReason.Value

    If Category = "Customer" Or _
       Category = "Field" And _
       Reason = "Accessory Failure" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Outbound" Or _
        Category = "Process" And _
        Reason = "Accessory Failure" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Customer" Or _
        Category = "Field" And _
        Reason = "Configuration Error" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Repair Tech" Or _
        Category = "QA" And _
        Reason = "Configuration Error" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Customer" Or _
       Category = "Field" And _
       Reason = "Clean/Maintenance" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Customer" Or _
        Category = "Field" And _
        Reason = "Data Entry" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Inbound" Or _
        Category = "Outbound" And _
        Reason = "Data Entery" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Process" And _
        Reason = "Design/Componet Issue" Then
        lblControllable.Caption = "No"
   ElseIf Category = "Customer" Or _
        Category = "Field" And _
        Reason = "Missing Parts" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Repair Tech" Or _
        Category = "Outbound" And _
        Reason = "Missing Parts" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Customer" Or _
       Category = "Field" And _
       Reason = "Clean/Maintenance" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Customer" Or _
        Category = "Field" And _
        Reason = "Physical Damage" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Repair Tech" And _
        Reason = "Physical Damage" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Field" And _
        Reason = "Received from Inventory" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Field" And _
        Reason = "Removal/Excess" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Process" And _
        Reason = "Repair Failure" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Repair Tech" And _
        Reason = "Repair Failure" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Customer" Or _
        Category = "Field" And _
        Reason = "Shipping Issues" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Outbound" And _
        Reason = "Shipping Issues" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Customer" Or _
        Category = "Field" And _
        Reason = "Software Image" Then
        lblControllable.Caption = "NO"
    ElseIf Category = "Repair Tech" Or _
        Category = "QA" Or _
        Category = "Support Tech" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Unresolved" And _
        Reason = "Undetermined" Then
        lblControllable.Caption = "Yes"
    ElseIf Category = "Customer" Or _
        Category = "Field" And _
        Reason = "Upgrade" Then
        lblControllable.Caption = "No"
    ElseIf Category = "Repair Tech" And _
        Reason = "Upgrade" Then
        lblControllable.Caption = "Yes"
    Else
        lblControllable.Caption = "???"
    End If

 End Sub

Aucun commentaire:

Enregistrer un commentaire