Forums
This topic is locked
Comparing Values
Posted 23 Jan 2003 10:39:40
1
has voted
23 Jan 2003 10:39:40 Peter Walker posted:
Hi guys - I have a problem that's doing me head in!I have a recordset that is basically a load of numbers. I want to be able to compare two values, and if the first value is less than the second, make the user aware - sounds simple enough!
The underlying database is MSAccess 97, and the fields are formatted as numeric.
Below is the code that I am using within the ASP page to write the message.
<b>If (CStr(rsIndicatorInformation.Fields.Item("01_02BoltonsFigure"




This works fine if the numbers are the same number of characters i.e. 90 and 80, but, if the numbers are, for example, 90 and 9 - then all goes pearshaped!
What am I doing wrong? Any help will be appreciated, and will stop my PC from being thrown through the nearest window!!
Thanks for your time
Pete
Replies
Replied 23 Jan 2003 11:30:47
23 Jan 2003 11:30:47 Owen Eastwick replied:
It's because you are comparing character strings, get rid of the CStr(rhubarb):
<%
If rsIndicatorInformation.Fields.Item("01_02BoltonsFigure"
.Value <= rsIndicatorInformation.Fields.Item("01_02MetroFourthQuartile"
.Value Then
Response.Write("This indicators performance puts it in the Metropolitan 4th Quartile"
Else
Response.Write(""
End If
%>
Regards
Owen.
---------------------------------------------------
Used programming books and web development software for sale (UK only):
www.tdsf.co.uk/Shop.htm
Multiple Parameter UD4 / Access 2000 Search Tutorial:
www.tdsf.co.uk/tdsfdemo/
Edited by - oeastwick on 23 Jan 2003 11:31:21
<%
If rsIndicatorInformation.Fields.Item("01_02BoltonsFigure"


Response.Write("This indicators performance puts it in the Metropolitan 4th Quartile"

Else
Response.Write(""

End If
%>
Regards
Owen.
---------------------------------------------------
Used programming books and web development software for sale (UK only):
www.tdsf.co.uk/Shop.htm
Multiple Parameter UD4 / Access 2000 Search Tutorial:
www.tdsf.co.uk/tdsfdemo/
Edited by - oeastwick on 23 Jan 2003 11:31:21
Replied 23 Jan 2003 15:51:28
23 Jan 2003 15:51:28 Peter Walker replied:
Thanks Owen
Pete
Pete