if then statement not working

B

bazango

Hi. I've got one of those wierd problems like when gravity stops working. It
may be because I have no idea what I'm doing. I am trying to compare a
previously entered value with a value coming from a form. Everything works
fine, but my if then statement (identical to others that do work) isn't
working. Here it is:

<%
dim SqlJunk

SqlJunk = "SELECT * FROM study1 WHERE ID = 652"

Set out = Server.CreateObject("ADODB.Recordset")
out.Open SqlJunk, cnn, 3,3

oldrecord=out("question2")
Response.Write oldrecord
Response.Write newrecord

if oldrecord = newrecord then
message = "It works!"
Response.Write message

end if
%>

So it writes the values 5 and 5; The values for the new record (from the
form) and the old record (from access table) respectively, but then fails to
write message, despite the fact that the if then condition should be
satisfied. It DOES work as expected if < is used, but not if > is used. It
also works if I say "IF oldrecord = 5" or "IF newrecord = 5." What am I not
getting? Both variables = 5, but not really? Help?
 
B

Brendan Reynolds

Answered in other thread in this newsgroup with subject "if then statement
not working in .asp file"
 
B

bazango

Oh. Brendan Reynolds informs me that "if CStr(oldrecord) = newrecord then" or
"if (oldrecord & "") = newrecord then" will work, because one of my variables
is a string, and one is a number. Duh. Thanks Brendan!

Sorry for the double post *I got "system not available message," no, honest!*
 
Top