Solved

ASP Run Loop Twice

Posted on 2009-05-05
5
445 Views
Last Modified: 2012-05-06
I want to run a loop twice. I know it would be more elegant to do all action in one loop but I'm struggling with the syntax and I need the same record set further down the code.  Is the first loop stopping the second?
While  (NOT rsAgents.EOF) 

'Do Action	

rsAgents.MoveNext()

Wend
 

While  (NOT rsAgents.EOF) 

'Do another Action	

rsAgents.MoveNext()

Wend

Open in new window

0
Comment
Question by:webdork
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
Pearl_export_ben earned 500 total points
ID: 24307152
Hope This Helps :)

If you are struggling with code, feel free to open a question with more code and I'll happily debug and explain it to you in more detail
'Scenario 1:

While  (NOT rsAgents.EOF) 

'Do Action      

rsAgents.MoveNext()

Wend
 

'This will take you back up to the top line of your code

rsAgents.MoveFirst()
 

While  (NOT rsAgents.EOF) 

'Do another Action      

rsAgents.MoveNext()

Wend
 
 

'Scenario 2:

While NOT rsAgents.EOF

   Do Action 1

   Do Action 2

   rsAgents.MoveNext

Wend

Open in new window

0
 
LVL 8

Expert Comment

by:Pearl_export_ben
ID: 24307162
And just to add a little more - Yes the first loop was stopping the second.  The first loop would loop through all your results to EOF (End Of File or ResultSet) and then the second loop would pick up where the first left off - at the end of your data - and thus wouldn't be able to manipulate the already played with data.

Ben
0
 
LVL 8

Expert Comment

by:Pearl_export_ben
ID: 24307201
Triple post - I know its naughty - sorry :(

'This will take you back up to the top line of your code
SHOULD BE
'This will take you to the first result in your file/resultset - not the first line of your code.

Ben
0
 

Author Comment

by:webdork
ID: 24307386
Too easy!
rsAgents.MoveFirst() did the trick.
Thanks.
0
 

Author Closing Comment

by:webdork
ID: 31578123
Oh Goody
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now