Link to home
Start Free TrialLog in
Avatar of jacobtdad
jacobtdadFlag for United States of America

asked on

I need to set mutlipe criteria IF Statement

I need to set a multiple criteria statement.  I have the code below that works for one set of criteria but I need  to add other levels.  I need to set the field "MR" if the value is greater than .95 and less than .98..  etc.  I have two more levels needed


Private Sub FinancailAccuracy_AfterUpdate()
If FinancailAccuracy <= 0.95 Then Financial_Quality_Rating = "NME"
Avatar of omgang
omgang
Flag of United States of America image

You can use a Select ...Case statement to accomplish this

Select Case FinancialAccuracy
    Case 1

    Case 2

    Case 3

    Case Else

End Select

OM Gang

Please provide the different cases you wish to test for and I'll provide a sample.
ASKER CERTIFIED SOLUTION
Avatar of omgang
omgang
Flag of United States of America 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 jacobtdad

ASKER

omgang.   Case 1   value between .01 and .94   Then Financial_Quality_Rating = "NME"
                 Case 2   value between .95 and .9849  Then Financial_Quality_Rating = "MR"
                  Case 3 value beetween .985 and .9949  Then ....= "CS"
                  Case 4  value between .9950 and .9979 Then ....=  "HS"
                  Case 5 Greater than .9979   Then = "AB"
Perfect answer.  Great response time....
Public Function CheckFinancialAccuracy()

On Error GoTo Err_CheckFinancialAccuracy
   
    Select Case Me.FinancialAccuracy
        Case 0.01 To 0.94
            strResult = "NME"
        Case 0.95 To 0.9849
            strReult = "MR"
        Case 0.985 To 0.9949
            strResult = "CS"
        Case 0.995 To 0.9979
            strResult = "HS"
        Case Is > 0.9979
            strResult = "AB"
        Case Else
            strResult = "value passed is outside of range"
    End Select
   
    Me.Financial_Quality_Rating = strResult

Exit_CheckFinancialAccuracy:
    Exit Function

Err_CheckFinancialAccuracy:
    MsgBox Err.Number & " (" & Err.Description & ") in procedure CheckFinancialAccuracy of Module Module9"
    Resume Exit_CheckFinancialAccuracy

End Function


OM Gang
jacobtdad, I posted another sample while you were accepting my solution.  Thank you very much.

OM Gang