Link to home
Start Free TrialLog in
Avatar of ca1358
ca1358

asked on

Help with If statements

I needs some help

This Access VBA.  I need to combine all these statements and make the last condition this: (if all statments are false then)
Else
  Range("P20") = Month(cboSecondary.Value) + 1 ' Standard Pool Month

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''This is my code.

If Len(cboSecondary.Value) > 3 Then
    If (cboSecondary.Value) = "11/29/2006" Then ' Jan Pool Month
        Range("P20") = 1
    Else
       End If
End If
       
If Len(cboSecondary.Value) > 3 Then
    If (cboPrimary.Value) = "30Govt" Then
       If (cboSecondary.Value) = "1/2/2006" Then ' Jan Pool Month
            Range("P20") = 1
       Else
          End If
    End If
    End If
   
If Len(cboSecondary.Value) > 3 Then
    If (cboPrimary.Value) = "30FHLM" Then
       If (cboSecondary.Value) = "1/2/2006" Then ' Feb Pool Month
         Range("P20") = 2
       Else
       
       End If
 End If
 End If
   
If Len(cboSecondary.Value) > 3 Then
    If (cboSecondary.Value) = "10/31/2006" Then ' Dec Pool Month
        Range("P20") = Month(cboSecondary.Value) + 2
     Else
       
       End If
End If

If Len(cboSecondary.Value) > 3 Then
    If (cboSecondary.Value) = "8/31/2006" Then
        Range("P20") = Month(cboSecondary.Value) + 2 'Oct Pool Month
    Else
       
End If
    End If

If Len(cboSecondary.Value) > 3 Then
    If (cboSecondary.Value) = "11/1/2006" Then 'Nov Pool Month
        Range("P20") = Month(cboSecondary.Value)
    Else
       
       End If
End If

If Len(cboSecondary.Value) > 3 Then
    If Month(cboSecondary.Value) = 12 Then
        Range("P20") = 1
End If
    End If

Avatar of Nightman
Nightman
Flag of Australia image

Try this:

If Len(cboSecondary.Value) > 3 Then
  If (cboSecondary.Value) = "11/29/2006" Then ' Jan Pool Month
    Range("P20") = 1
  End If
 
  If (cboPrimary.Value) = "30Govt" Then
    If (cboSecondary.Value) = "1/2/2006" Then ' Jan Pool Month
      Range("P20") = 1
    End If
  End If

  If (cboPrimary.Value) = "30FHLM" Then
     If (cboSecondary.Value) = "1/2/2006" Then ' Feb Pool Month
       Range("P20") = 2
     End If
  End If

    If (cboSecondary.Value) = "10/31/2006" Then ' Dec Pool Month
        Range("P20") = Month(cboSecondary.Value) + 2
    End If

  If (cboSecondary.Value) = "8/31/2006" Then
    Range("P20") = Month(cboSecondary.Value) + 2 'Oct Pool Month
  End If

  If (cboSecondary.Value) = "11/1/2006" Then 'Nov Pool Month
      Range("P20") = Month(cboSecondary.Value)
    End If

  If Month(cboSecondary.Value) = 12 Then
      Range("P20") = 1
    End If

Else      
    Range("P20") = Month(cboSecondary.Value) + 1 ' Standard Pool Month
End If
Avatar of lunchbyte
lunchbyte

If Len(cboSecondary.value) > 3 Then


    If (cboSecondary.value) = "11/29/2006" Then ' Jan Pool Month
        Range("P20") = 1
    ElseIf (cboPrimary.value) = "30Govt" Then
       If (cboSecondary.value) = "1/2/2006" Then ' Jan Pool Month
            Range("P20") = 1
       End If
    ElseIf (cboPrimary.value) = "30FHLM" Then
       If (cboSecondary.value) = "1/2/2006" Then ' Feb Pool Month
         Range("P20") = 2
       End If
    ElseIf (cboSecondary.value) = "10/31/2006" Then ' Dec Pool Month
            Range("P20") = month(cboSecondary.value) + 2
        End If
    ElseIf (cboSecondary.value) = "8/31/2006" Then
            Range("P20") = month(cboSecondary.value) + 2 'Oct Pool Month
        End If
    ElseIf (cboSecondary.value) = "11/1/2006" Then 'Nov Pool Month
            Range("P20") = month(cboSecondary.value)
        End If
    ElseIf month(cboSecondary.value) = 12 Then
            Range("P20") = 1
        End If
    Else
        If month(cboSecondary.value) = 12 Then
            Range("P20") = 1
        End If
    End If
End If
Avatar of Dany Balian
If Len(cboSecondary.Value) > 3 Then
    If (cboSecondary.Value) = "11/29/2006" Then
        range("P20") = 1
    ElseIf (cboPrimary.Value) = "30Govt" And (cboSecondary.Value = "1/2/2006") Then range("P20") = 1
    ElseIf (cboPrimary.Value) = "30FHLM" And (cboSecondary.Value = "1/2/2006") Then range("P20") = 2
    ElseIf (cboSecondary.Value) = "10/31/2006" Then range("P20") = Month(cboSecondary.Value) + 2
    ElseIf (cboSecondary.Value) = "8/31/2006" Then range("P20") = Month(cboSecondary.Value) + 2        'Oct Pool Month
    ElseIf (cboSecondary.Value) = "11/1/2006" Then range("P20") = Month(cboSecondary.Value)  'Nov Pool Month
    ElseIf Month(cboSecondary.Value) = 12 Then range("P20") = 1
    Else
        range("P20") = Month(cboSecondary.Value) + 1    ' Standard Pool Month
    End If
End If
ASKER CERTIFIED SOLUTION
Avatar of Dany Balian
Dany Balian
Flag of Lebanon image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ca1358

ASKER

Thank you!