Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then Evaluating a range 1

Status
Not open for further replies.

Xtremlylost

Technical User
Jul 18, 2002
25
0
0
US
I have the following in a range of statements but the form isn't evaluating it correctly and is grabbing the wrong number. I am sure it is the way I am putting it together and would appreciate some help in getting it to work. The ranges should be clear of what I am looking for. The code however does not seem to see the range and is going to the next statement pulling the incorrect percentage to use for calculations. It appears that I need to better define the range to evaluate but I just don't know how...

If Me.FrmDoorTotal <= 9 Then
Me.FrmPrct = 0.14
ElseIf Me.FrmDoorTotal > 9 <= 24 Then
Me.FrmPrct = 0.31
ElseIf Me.FrmDoorTotal > 24 <= 99 Then
Me.FrmPrct = 0.34
ElseIf Me.FrmDoorTotal > 99 Then
Me.FrmPrct = 0.38
End If

Any help will be appreciated.

Sometimes the view is perfect right where you are and sometimes falling is the only way to know it.
 
Maybe?

If Me.FrmDoorTotal <= 9 Then
Me.FrmPrct = 0.14
ElseIf Me.FrmDoorTotal > 9 AND Me.FrmDoorTotal <= 24 Then
Me.FrmPrct = 0.31
ElseIf Me.FrmDoorTotal > 24 AND Me.FrmDoorTotal <= 99 Then
Me.FrmPrct = 0.34
ElseIf Me.FrmDoorTotal > 99 Then
Me.FrmPrct = 0.38
End If
 
I knew there had to be another operator to separate them I just had no idea how to go about it. Works perfect!!

Thanks a lot!!
Xtremlylost

Sometimes the view is perfect right where you are and sometimes falling is the only way to know it.
 
A simpler way:
If Me.FrmDoorTotal <= 9 Then
Me.FrmPrct = 0.14
ElseIf Me.FrmDoorTotal <= 24 Then
Me.FrmPrct = 0.31
ElseIf Me.FrmDoorTotal <= 99 Then
Me.FrmPrct = 0.34
Else
Me.FrmPrct = 0.38
End If

Another way is to use the Select Case instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top