Link to home
Create AccountLog in
Avatar of jlcannon
jlcannon

asked on

ELSE IF not working on ASP page

I have an ELSE IF statement that I cannot seem to get the syntax correct.

<%
PPMVal = PPMNum-12
If PPMVal = rs.fields("Annual off-Line Inspection")then   
        PPMValCode= rs.Fields("Annual off-Line Inspection Code")  
    else if
        PPMVal = rs.Fields("5year Major Inspection")then
        PPMValCode= rs.Fields("5year Major Inspection Code")  
    else if
  		PPMVal = rs.Fields("10 year Major Inspection")then
        PPMValCode= rs.Fields("10 year Major Inspection Code")  
    else if
		PPMVal = rs.Fields("15 year Major Inspection")then
        PPMValCode= rs.Fields("15 year Major Inspection Code")  
    else if
		PPMVal = rs.Fields("20 year Major Inspection")then
        PPMValCode= rs.Fields("20 year Major Inspection Code") 

    end if 

%>

Open in new window


What I am trying to do is basically take the number I am getting for PPMNum subtract 12 and take that number and which ever condition is true make the one thats true the variable PPMValCode.
Avatar of Gary
Gary
Flag of Ireland image

Probably rs.fields("Annual off-Line Inspection") and the rest of those fields are a string and you are comparing them against a number
Try the amendment below and see if it works

PPMVal = PPMNum-12
PPMVal =Cstr(PPMVal)
If PPMVal = rs.fields("Annual off-Line Inspection")then  
...
Avatar of jlcannon
jlcannon

ASKER

The error I am getting is
_______________________________________________________
Microsoft VBScript compilation error '800a03ea'

Syntax error

/energysystc/electricalppmChlorAlkali.asp, line 1580

else if
__________________________________________________________
else if

should be

elseif
Have done it both ways and gives the same syntax error
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account