473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

What is wrong with my code??

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

Feb 27 '06 #1
7 1348
Do Until rs3.EOF
MsgBox rs3.Fields("txtTopic").Value
Loop

Feb 27 '06 #2
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

Feb 27 '06 #3
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

Feb 27 '06 #4
Duh!! MoveNext.
Something simple. :) :) :)
Thank you, Joost.
:) tom

Feb 27 '06 #5
That's because I was stupid.

Feb 27 '06 #6
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

"tlyczko" <tl*****@gmail.com> wrote in message
news:11**********************@t39g2000cwt.googlegr oups.com...
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

Feb 28 '06 #7
No, I was. :)
I forgot the MoveNext.
Thank you!
:) tom

Feb 28 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this...
56
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
9
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
20
by: Daniel.C | last post by:
Hello. I just copied this code from my book with no modification : #include <stdio.h> /* count characters in input; 1st version */ main() { long nc; nc = 0;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.