code not working

sunset1215

Registered User.
Local time
Tomorrow, 05:40
Joined
Apr 7, 2011
Messages
46
hi all,

i've a code that returns the flow type based on their average results.

my code is this:
'auto update flow type
Dim Avg
Avg = DLookup("AvgOfexprLoad", "qryAvgLoad2", "[fkPerID] = " & Me.pkPerID)
If 0 <= Avg <= 3.9 Then
strFlow.Value = "Light"
If 4 <= Avg <= 7.9 Then
strFlow.Value = "Moderate"
If 8 <= Avg <= 11.9 Then
strFlow.Value = "Heavy"
If Avg >= 12 Then
strFlow.Value = "Very Heavy"
Else
End If
End If
End If
End If
End Sub

"qryavgload2" is a query i created, which selects the ID and average.

no error came up, but the results are "heavy" for most of the records, even if it should be "moderate" or "light". only the "very heavy works".
any help or advice is greatly appreciated.
 
Code:
If 0 [B]<=[/B] Avg [B]<=[/B] 3.9 Then
What are you trying to say here? The syntax youhave entered is wrong.
 
What are you trying to say here? The syntax youhave entered is wrong.

my avg is a number, so if the avg is between 0 to 3.9, the flow type should be light. it is the same for the rest.
 
You would be better of using a Select Case Statement rather than if's

Code:
Select Case Avg
   Case <= x

   Case <= y

   Case <= z


   Case Else

End Select
 

Users who are viewing this thread

Back
Top Bottom