If Statement using les than and more than

jojo86

Registered User.
Local time
Today, 17:06
Joined
Mar 7, 2007
Messages
80
Hi

I have a field that needs to be populated with percentages according to the site area given, which is this:
SITE_AREA GN_Ratio
Less than 0.4 100%
Between 0.4 and 2 90%
Between 2 and 10 75%
More than 10 50%

I am attempting to try and populate a field on one of my forms using the following code, but it doesn't seem to be working:
Code:
If SITE_AREA <= "0.4" Then
GN_Ratio = "100.00%"
Else
If SITE_AREA >"0.4" < "2" Then
GN_Ratio = "90.00%"
Else
If SITE_AREA >="2" < "10" Then
GN_Ratio = "75.00%"
Else
GN_Ratio = "50.00%"
End If
End If
End If

I have put this code in the On Load event and the On Current event of the form. Just to mention, this form (Yield) is a subform in the main form (Primary).

I need to get this finished before the end of play today due to christmas so any help would be much appreciated! Thanks
 
You need to use AND
so:
If SITE_AREA >"0.4" AND < "2" Then


I would also suggest you use SELECT CASE rather than all the IF's
 
You need to use AND
so:
If SITE_AREA >"0.4" AND < "2" Then


I would also suggest you use SELECT CASE rather than all the IF's
I have just tried to put in the AND bit and it now says "Compile Error: Expected: expression" and the < is highlighted. Don't know what you mean by SELECT CASE either.
 
I have just tried to put in the AND bit and it now says "Compile Error: Expected: expression" and the < is highlighted. Don't know what you mean by SELECT CASE either.

Try
Code:
If SITE_AREA >"0.4" AND SITE_AREA< "2" Then

IF SITE_AREA is defined as a number then try

Code:
If SITE_AREA > 0.4 AND SITE_AREA <  2 Then

See Access help for more info on CASE
 
Try this
Select Case SITE_AREA

Case Is <= 0.4
GN_Ratio = "100.00%"

Case 0.4 To 2
GN_Ratio = "90.00%"

Case 2 To 10
GN_Ratio = "75.00%"

Case Else
GN_Ratio = "50.00%"

End Select
 

Users who are viewing this thread

Back
Top Bottom