I am writing code to get a subset of table records, but it is not
looping properly through the fields, it keeps getting stuck in some
sort of infinite loop and I have to be able to walk the whole
recordset.
Am I not using the do loop properly??
dim db as DAO.database
dim rs3 as DAO.recordset
dim strSQL as string
strSQL = "SELECT tblComments.AuditID, tblComments.txtTopic,
tblComments.memAuditTopicComments"
strSQL = strSQL & " FROM tblComments"
strSQL = strSQL & " WHERE tblComments.AuditID=" & lngAuditID
Set rs3 = db.OpenRecordset(strSQL)
rs3.MoveFirst
rs3.MoveLast
Do Until rs3.EOF
'this should show different values, but gets stuck on the value of the
last record
MsgBox rs3.Fields("txtTopic").Value
Loop
I actually need to run a Select Case statement inside the Do loop to
update various records in the recordset, it is a small recordset, <20
records.
Thank you, Tom
Lyle Fairfield - 27 Feb 2006 19:41 GMT
Do Until rs3.EOF
MsgBox rs3.Fields("txtTopic").Value
Loop
tlyczko - 27 Feb 2006 19:50 GMT
Hello Lyle,
Please excuse me, I cannot see any difference between your suggestion
and my code that I posted above.
Please tell me the difference between what you typed and what I have??
My code gets stuck in an endless loop when it should show 8-10
different values per recordset.
Thank you, Tom
Lyle Fairfield - 27 Feb 2006 20:15 GMT
That's because I was stupid.
tlyczko - 28 Feb 2006 21:07 GMT
No, I was. :)
I forgot the MoveNext.
Thank you!
:) tom
Joost - 27 Feb 2006 19:46 GMT
rs3.MoveLast moves the current record to the last record of the
recordset so rs3.EOF
is always inmediately true so that's why you get stuck on the value of
the
last record
Try
rs3.MoveFirst
Do Until rs3.EOF
MsgBox rs3.Fields("txtTopic").Value
rs3.moveNext
Loop
Succes
tlyczko - 27 Feb 2006 19:52 GMT
Duh!! MoveNext.
Something simple. :) :) :)
Thank you, Joost.
:) tom
Jeff - 28 Feb 2006 08:14 GMT
Hi Tom
Do Until rs3.EOF
MsgBox rs3.Fields("txtTopic").Value
rs3.MoveNext
Loop
You need the 'MoveNext' to move to the next record.
Jeff Pritchard
________________
Asken Research Pty. Ltd.
Access Database Developers
http://www.asken.com.au
>I am writing code to get a subset of table records, but it is not
> looping properly through the fields, it keeps getting stuck in some
[quoted text clipped - 24 lines]
>
> Thank you, Tom