Question
help with this IF, Else, Else If and End If problem? ASP/VB
Hoping someone can help me with this. I have three database
tables,
orderdetails, paidorders, ordercomplete and the following recordset:
<%
Dim rsOrderSearch
Dim rsOrderSearch_cmd
Dim rsOrderSearch_numRows
Set rsOrderSearch_cmd = Server.CreateObject ("ADODB.Command")
rsOrderSearch_cmd.ActiveConnection = MM_connNAME_STRING
rsOrderSearch_cmd.CommandText = "SELECT orderID, (SELECT COUNT(*) FROM
dbo.tblpaidorders WHERE dbo.qryorderdetails.orderID =
dbo.tblpaidorders.orderID) AS PAIDORDER, (SELECT COUNT(*) FROM
dbo.tblordercomplete WHERE dbo.qryorderdetails.orderID =
dbo.tblordercomplete.orderID) AS COMPLETEORDER, itemdescription FROM
dbo.qryorderdetails WHERE orderID = ? OR customerID = ? OR itemdescription
LIKE ? ORDER BY orderdate DESC"
rsOrderSearch_cmd.Prepared = true
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param1", 5, 1, -1,
rsOrderSearch__MMColParam) ' adDouble
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param2", 5, 1, -1,
rsOrderSearch__MMColParam1) ' adDouble
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param3", 200, 1, 255, "%" +
rsOrderSearch__MMColParam2 + "%") ' adVarChar
Set rsOrderSearch = rsOrderSearch_cmd.Execute
rsOrderSearch_numRows = 0
%>
If the orderID appears in the ordercomplete table (thus COMPLETEORDER would
have a COUNT value of 1), I want to display "Completed".
If the orderID appears in the paidorders table (thus PAIDORDER would have a
COUNT value of 1), I want to display "Awaiting Pickup/Delivery".
For everything else, I want to display "Open Job".
For some reason, the following doesn't display the "Awaiting
Pickup/Delivery" option, but seems to be displaying "Completed" correctly.
I've tried various combinations, but it looks correct to me! Is it?:
<%IF (rsOrderSearch.Fields.Item("COMPLETEORDER").Value) > 0 Then%>
<span class="greentext">Completed</span>
<%Else%>
<%IF (rsOrderSearch.Fields.Item("PAIDORDER").Value) > 0 Then%>
<span class="orangetext">Awaiting Pickup/Delivery</span>
<%Else%>
<span class="redtext">Open Job</span>
<%End If%>
<%End If%>
Also, the above code is in a table cell within a repeat region. If I move
this to a different table cell within the same repeat region, it doesn't
display at all! This seems more like a bug to be honest, but considering
the above code doesn't work, I'm wondering if that is the reason?
If anyone can help, I'd really appreciate it. Thanks.
Regards
Nath.
orderdetails, paidorders, ordercomplete and the following recordset:
<%
Dim rsOrderSearch
Dim rsOrderSearch_cmd
Dim rsOrderSearch_numRows
Set rsOrderSearch_cmd = Server.CreateObject ("ADODB.Command")
rsOrderSearch_cmd.ActiveConnection = MM_connNAME_STRING
rsOrderSearch_cmd.CommandText = "SELECT orderID, (SELECT COUNT(*) FROM
dbo.tblpaidorders WHERE dbo.qryorderdetails.orderID =
dbo.tblpaidorders.orderID) AS PAIDORDER, (SELECT COUNT(*) FROM
dbo.tblordercomplete WHERE dbo.qryorderdetails.orderID =
dbo.tblordercomplete.orderID) AS COMPLETEORDER, itemdescription FROM
dbo.qryorderdetails WHERE orderID = ? OR customerID = ? OR itemdescription
LIKE ? ORDER BY orderdate DESC"
rsOrderSearch_cmd.Prepared = true
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param1", 5, 1, -1,
rsOrderSearch__MMColParam) ' adDouble
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param2", 5, 1, -1,
rsOrderSearch__MMColParam1) ' adDouble
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param3", 200, 1, 255, "%" +
rsOrderSearch__MMColParam2 + "%") ' adVarChar
Set rsOrderSearch = rsOrderSearch_cmd.Execute
rsOrderSearch_numRows = 0
%>
If the orderID appears in the ordercomplete table (thus COMPLETEORDER would
have a COUNT value of 1), I want to display "Completed".
If the orderID appears in the paidorders table (thus PAIDORDER would have a
COUNT value of 1), I want to display "Awaiting Pickup/Delivery".
For everything else, I want to display "Open Job".
For some reason, the following doesn't display the "Awaiting
Pickup/Delivery" option, but seems to be displaying "Completed" correctly.
I've tried various combinations, but it looks correct to me! Is it?:
<%IF (rsOrderSearch.Fields.Item("COMPLETEORDER").Value) > 0 Then%>
<span class="greentext">Completed</span>
<%Else%>
<%IF (rsOrderSearch.Fields.Item("PAIDORDER").Value) > 0 Then%>
<span class="orangetext">Awaiting Pickup/Delivery</span>
<%Else%>
<span class="redtext">Open Job</span>
<%End If%>
<%End If%>
Also, the above code is in a table cell within a repeat region. If I move
this to a different table cell within the same repeat region, it doesn't
display at all! This seems more like a bug to be honest, but considering
the above code doesn't work, I'm wondering if that is the reason?
If anyone can help, I'd really appreciate it. Thanks.
Regards
Nath.