473,398 Members | 2,125 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,398 software developers and data experts.

easy syntax q: for each record in recordset

Suppose I've built a recordset. I want some code to run for each record in
the recordset in a "loop." In ASP VBScript, how would you express the
following:

For each [record] in [recordset]
[run some code]
next

The only thing I'm really fuzzy on is the syntax for describing each
recordset row. Thanks for any help.
Jul 19 '05 #1
5 19536
Do While Not TheRecordset.EOF
'run code, such as:
response.write TheRecords.Fields.Item(0).Value & "<br>"
Loop

That is one way.

Ray at work

"Ken Fine" <ke*****@u.washington.edu> wrote in message
news:bq**********@nntp6.u.washington.edu...
Suppose I've built a recordset. I want some code to run for each record in
the recordset in a "loop." In ASP VBScript, how would you express the
following:

For each [record] in [recordset]
[run some code]
next

The only thing I'm really fuzzy on is the syntax for describing each
recordset row. Thanks for any help.

Jul 19 '05 #2
"Ken Fine" <ke*****@u.washington.edu> wrote in message
news:bq**********@nntp6.u.washington.edu...
Suppose I've built a recordset. I want some code to run for each
record in the recordset in a "loop."


rsData.Open( ...

' Depending on the recordset's options, you /might/ need
rsData.MoveFirst

' Then, simply
Do While Not rsData.EOF
' Do something useful with the "current" record
Response.Write rsData.Fields( "PK1" ).Value & "<p>" ' say

' Get the next record
rsData.MoveNext
Loop

HTH,
Phill W.
Jul 19 '05 #3
Ooops. That's an endless loop that I posted. I forgot a rather important
part...

Do While Not TheRecordset.EOF
'run code, such as:
response.write TheRecords.Fields.Item(0).Value & "<br>"
THERECORDSET.MOVENEXT
Loop

Ray at work

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Do While Not TheRecordset.EOF
'run code, such as:
response.write TheRecords.Fields.Item(0).Value & "<br>"
Loop

That is one way.

Ray at work

"Ken Fine" <ke*****@u.washington.edu> wrote in message
news:bq**********@nntp6.u.washington.edu...
Suppose I've built a recordset. I want some code to run for each record in the recordset in a "loop." In ASP VBScript, how would you express the
following:

For each [record] in [recordset]
[run some code]
next

The only thing I'm really fuzzy on is the syntax for describing each
recordset row. Thanks for any help.


Jul 19 '05 #4
Ken Fine wrote:
Suppose I've built a recordset. I want some code to run for each
record in the recordset in a "loop." In ASP VBScript, how would you
express the following:

For each [record] in [recordset]
[run some code]
next

The only thing I'm really fuzzy on is the syntax for describing each
recordset row. Thanks for any help.


dim arData, rs, i
'open the recordset then
if not rs.EOF then arData = rs.GetRows
rs.close: set rs = nothing
'close and destroy the connection here as well
for i = 0 to Ubound(arData,2)
'do your stuff
next

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #5
Exactly what I need. Thanks.

-KF
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:bq*********@yarrow.open.ac.uk...
"Ken Fine" <ke*****@u.washington.edu> wrote in message
news:bq**********@nntp6.u.washington.edu...
Suppose I've built a recordset. I want some code to run for each
record in the recordset in a "loop."


rsData.Open( ...

' Depending on the recordset's options, you /might/ need
rsData.MoveFirst

' Then, simply
Do While Not rsData.EOF
' Do something useful with the "current" record
Response.Write rsData.Fields( "PK1" ).Value & "<p>" ' say

' Get the next record
rsData.MoveNext
Loop

HTH,
Phill W.

Jul 19 '05 #6

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

Similar topics

4
by: Joe User | last post by:
Hi all....I have a feeling this is going to be one of those twisted query questions, but here it goes anyways.... I want to generate a report that shows the chronology of events (represented by...
20
by: Greg | last post by:
I'm fairly new to access (using 2002) and am setting up a DB for work. along with each record the user also needs to make a flow diagram (previously, these reports were composed in word and they...
1
by: Kevin.S.Campbell | last post by:
Greetings, I'm trying to run a sql query on a continous form. I have the query working correctly the way I want it. I want this query to be displayed on the form in the text box on the load...
3
by: larry | last post by:
Hi, Is there a way to calculate the sum of the numbers in each field for each record in the recordset returned from the query? Do I have to use VBScript? Thanks, Larry
6
by: slider | last post by:
Hey all i am using Access 2003 on Win Xp and i have been trying to make this code send emails to the users stored on each record. So far is works, except in the body of the email i need it to say a...
3
by: kevinj | last post by:
Greetings, I am creating a "stoplight" type report that is based on the number of days between dates, the field will be highlighted in red, yellow, or green. I am able to change the background...
1
by: accessvbanewbie | last post by:
I would like to export a recordset from access to excel but after each record is exported I want to insert a new row. The first recordset does this ok. However, the second recordset onwards does not...
47
by: Arli | last post by:
I have a database that is running with Access 2003. The Database is used to track orders and for putting time stamps on those orders. I need to put a pop up message on the database that alerts the...
7
by: ggfota | last post by:
I have problem creating Access (Continuous) Form with indepenent CheckBox for each record. The user should be able to select records that will be processed by VBA based on ChceckBox value. When I...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.