I am out of my mind now. Can anybody please help me debug this piece of
code? I want to use nested if statement to check several conditions. But
varID = RS("GroupNum") seems not working since it always return "wrong ID."
even though the ID matches the GroupNum. I tried to use if RS("GroupNum")
then..it returns table when there's data, but when there's no record for
this GroupNum, it generated Error Type: > > ADODB.Field (0x800A0BCD) > >
Either BOF or EOF is True, or the current record has been deleted. > >
Requested operation requires a current record.
It supposed to return message from inner if else statement:"you haven't
bought anything currently." But I never saw this message. Please tell me
what is wrong. I appreciate any of your help. Ping
This is my code:
<%
' collect input from user.
'==========================
varID = request.form("ID")
dim RS
' open RecordSet with possible ID matches.
'=========================================
set RS = server.CreateObject("ADODB.Recordset")
RS.Open "SELECT * " & _
"FROM Table1 " & _
"WHERE (GroupNum = " & varID & " " & _
"OR DeptNum = " & varID & " " objConn, adOpenForwardOnly, adLockReadOnly,
adCmdText
'Check to see if the input number matches group number
'=====================================================
If varID = RS("GroupNum") then
If not RS.eof then
response.write "You have following items:" &_
"<table>" & _
"<tr>" &_
"<th>Item Number </th>" &_
"<th>Value</th>" &_
"<th>Purchase Date</th>" &_
do while not RS.eof
response.write _
"<tr align=center>" &_
" <TD> " & RS("Item_Num") & "</TD>" & _
" <td>" & FormatCurrency(RS("Value")) & "</td>" &_
" <td>" & FormatDateTime(RS("Purchase_Date"),2) & "</td>"
&_
"</tr>"
RS.MoveNext
Loop
response.write "</table>"
else
response.write "You haven't bought anything recently"
end if
' Check to see if the input number matches department number
'===========================================================
ElseIf varID = RS("DeptNum") then
If not RS.eof then
response.write "You have bought" &_
"<table>" & _
"<tr>" &_
"<th>Item Number </th>" &_
"<th>Value</th>" &_
"<th>Purchase Date</th>" &_
do while not RS.eof
response.write _
"<tr align=center>" &_
" <TD> " & RS("ItemNum") & "</TD>" & _
" <td>" & FormatCurrency(RS("Value")) & "</td>" &_
" <td>" & FormatDateTime(RS("Purchase_Date"),2) & "</td>"
&_
"</tr>"
RS.MoveNext
Loop
response.write "</table>"
else
response.write "You haven't bought anything recently."
end if
else
response.write " wrong ID."
end if
RS.close
set RS = nothing
%>