Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check box results

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
I have a page where I display a list of Years and Months from a table and a corresponding list of checkboxes, so that the user can choose whichever date (can be more than one choice) to delete from the table. The problem is that I have something wrong with the looping which I cannot find. Here is the code of the looping, the problem is that
its looping on the same record instead of going through all the recordset and deleting the Id where I have clicked the checkbox!
Here is my code:-

if not rsClientStats.EOF or NOT rsClientStats.BOF then
rsCLientStats.movefirst
do
if NOT CheckVal = "" then
'*** Delete the record from the database
sqlDeleteStat = "DELETE FROM Stats "
sqlDeleteStat = sqlDeleteStat & "WHERE clientID =" & ChosenClient & " "
sqlDeleteStat = sqlDeleteStat & "AND statsID =" & CheckVal & ";"
response.Write(sqlDeleteStat)
response.Write(&quot;<p></p>&quot;)
' rsDeleteStat.Open (sqlDeleteStat)
end if
rsClientStats.movenext
loop until rsClientStats.EOF
end if
 
yep...it will

if not rsClientStats.EOF or NOT rsClientStats.BOF then
rsCLientStats.movefirst this tells the cursor to move back to the first record every time. you need to place is outside the loop...though you really don't need it, the cursor is automatically at the first position, so just delete the line...or use this area for an error message like: No Data Found Please Try Again
i would also change the loop structure to this:
end if
do while not rsClientStats.eof

if NOT CheckVal = &quot;&quot; then
'*** Delete the record from the database
sqlDeleteStat = &quot;DELETE FROM Stats &quot;
sqlDeleteStat = sqlDeleteStat & &quot;WHERE clientID =&quot; & ChosenClient & &quot; &quot;
sqlDeleteStat = sqlDeleteStat & &quot;AND statsID =&quot; & CheckVal & &quot;;&quot;
response.Write(sqlDeleteStat)
response.Write(&quot;<p></p>&quot;)
' rsDeleteStat.Open (sqlDeleteStat)
end if
rsClientStats.movenext
loop

hth Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Thanks Bastien, I did this and it worked:-

if not rsClientStats.EOF or NOT rsClientStats.BOF then
For n = 0 to VarN-1
CheckVal = request.Form(&quot;menuCheck&quot; & n+1)
if NOT CheckVal = &quot;&quot; then
'*** Delete the record from the database
sqlDeleteStat = &quot;DELETE FROM Stats &quot;
sqlDeleteStat = sqlDeleteStat & &quot;WHERE clientID =&quot; & ChosenClient & &quot; &quot;
sqlDeleteStat = sqlDeleteStat & &quot;AND statsID =&quot; & CheckVal & &quot;;&quot;
response.Write(sqlDeleteStat)
end if
next
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top