Solved

Help with If statements

Posted on 2006-11-08
5
185 Views
Last Modified: 2010-04-30
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

0
Comment
Question by:ca1358
5 Comments
 
LVL 29

Expert Comment

by:Nightman
Comment Utility
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
0
 
LVL 5

Expert Comment

by:lunchbyte
Comment Utility
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
0
 
LVL 11

Expert Comment

by:Dany Balian
Comment Utility
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
0
 
LVL 11

Accepted Solution

by:
Dany Balian earned 500 total points
Comment Utility
or maybe something like this?

If Len(cboSecondary.Value) > 3 Then
    Select Case cboSecondary.Value
        Case "11/29/2006": range("P20") = 1
        Case "1/2/2006":
            If cboPrimary.Value = "30Govt" Then
                range("P20") = 1
            ElseIf cboPrimary.Value = "30FHLM" Then
                range("P20") = 2
            End If
        Case "10/31/2006": range("P20") = Month(cboSecondary.Value) + 2
        Case "8/31/2006": range("P20") = Month(cboSecondary.Value) + 2
        Case "11/1/2006": range("P20") = Month(cboSecondary.Value)
        Case Else:
            If Month(cboSecondary.Value) = 12 Then range("P20") = 1 Else range("P20") = Month(cboSecondary.Value) + 1
    End Select
End If

hope this helps..

Dan
0
 

Author Comment

by:ca1358
Comment Utility
Thank you!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now