What's wrong with this loop???

Results 1 to 3 of 3

Thread: What's wrong with this loop???

  1. #1
    Join Date
    Dec 1969

    Default What's wrong with this loop???

    I&#039ve got a database with questions and multiple choice answers. I want to create a form with the question, followed by radio boxes for each possible choice answer. My query pulls in all questions and all answers, sorted by question id (QID) and answer id (AID). In order to determine when one question ends and the next begins, I assign the value of the question id to a variable and loop through the answers until the value changes. This is working great...until I hit the bottom of the recordset. At that point, after everything has been written, I get an exception error. Does anybody see anything wrong with this loop?<BR><BR>************************************* ***********************<BR>dim QID<BR>dim questionanswer<BR>if Not RecordSet.eOF Then<BR>RecordSet.MoveFirst<BR>do while not recordset.eof<BR> Response.Write(RecordSet.Fields("Qtext"))<BR> QID=recordset.fields("qid")<BR> do while recordset.fields("qid")=qid<BR><BR> Response.Write("&#060;input type=&#039radio&#039 value=" & recordset.fields("AID") & " name=" & RECORDSET.FIELDS("QID") & "&#062; " & RecordSet.Fields("AID") & ": " & recordset.fields("atext") & "<BR>")<BR><BR> if recordset.eof then<BR> exit do<BR> else<BR> recordset.movenext<BR> end if<BR> Loop<BR> response.write("&#060;HR&#062;")<BR> loop<BR>End If<BR>******************************************** ****************<BR>Any help would be great. Thanks.

  2. #2
    Leungas Guest

    Default RE: What's wrong with this loop???

    try to move your EOF check after you movenext<BR><BR>Hope this helps

  3. #3
    Join Date
    Dec 1969

    Default RE: What's wrong with this loop???

    &nbsp;<BR>I think you missed off a movenext <BR>below is the bottom of your code<BR><BR>Loop<BR>response.write("&#060;HR&#062; ")<BR>**recordset.movenext**<BR>loop<BR>End If<BR><BR>You should check out "DataShaping" and "Multiple Recordsets"<BR>there&#039s a ton of functionality to build reall intelligent recordsets that don&#039t loop newarly as complicated as this one..<BR>strongly recommended<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts