PDA

View Full Version : Microsoft VBScript compilation (0x800A03EA)


IraFashua
04-06-2009, 11:25 AM
this is my error that i get..
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/e-training/DailyRpt.asp, line 175, column 47
else if (month(rs7("CourseDateStart"))>= 4 AND <=6) then

and this is my coding..
<%

sql = "SELECT * from Training WHERE StaffName='" & rs2("StaffName") & "' AND Company='TSB'"
SET RS7 = Conn.Execute(sql)
Do While not RS7.EOF

%>
<% if ((month(rs7("CourseDateStart"))) => 1 and (month(rs("CourseDateStart"))) <=3) then response.Write("Q1")%><br>
<%else if (month(rs7("CourseDateStart"))>= 4 AND <=6) then
response.Write("Q2")%><br>
<%else if (month(rs7("CourseDateStart"))>= 7 AND <=9) then
response.Write("Q3")%><br>
<%else if (month(rs7("CourseDateStart")) >=10 AND <=12) then
response.Write("Q4")%><br>
<%end if%><%end if%><%end if%>

<%rs7.MoveNext
loop
rs7.Close
set rs7 = Nothing
%>
can onyone help me..
please!!!!:)

TheShaner
04-06-2009, 07:49 PM
Your If statements are incorrect. When you use a logical operator (AND, OR, etc.), you must set it up like so:
If(test [comparison operator] value [logical operator] test2 [comparison operator] value2) Then
Which would yield something like:
If(day > 31 And month = 12) Then

So your ElseIf statements like this one here:
else if (month(rs7("CourseDateStart"))>= 4 AND <=6) then
Should be set up like your first If statement:
if ((month(rs7("CourseDateStart"))) => 1 and (month(rs("CourseDateStart"))) <=3)
So the corrected version would look like this:
else if (month(rs7("CourseDateStart"))>= 4 AND month(rs7("CourseDateStart"))<=6) then
Do this for your other two ElseIf statements.

-Shane

Old Pedant
04-06-2009, 08:34 PM
As a minor point:

Usually, you should avoid getting a value from any collection more than once, because collection lookups are a lot slower than other things in VBScript. Yes, that includes looking up the value of a recordset field.

So, *IF* you can easily do so:

<%
courseStart = rs7("CourseDateStart")
monthCourseStart = Month(courseStart)
...
If ...

Elseif monthCourseStart >= 4 AND monthCourseStart <= 6 Then
...


ALSO... MAJOR MISTAKE IN THE CODE!

ELSEIF should be ALL ONE WORD! No paces!

If you code it as two words, then you have to have an END IF for each IF.

Only if you do it as one word can you "chain" a bunch of ELSEIF statements as you are doing.