?
Solved

question about do while loop?

Posted on 2003-02-21
6
Medium Priority
?
183 Views
Last Modified: 2010-04-07
What's the correct coding when you have a access table you want to loop thru each record to do processing and then after it has processed the last record exits the loop
for example pseudo code:

bring table to workspace
go to first record
do while not end of table
 processing stuff here for each record-queries and etc.
 move to next record coding here if needed
loop  


thanks
0
Comment
Question by:countyworker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 11

Accepted Solution

by:
rdrunner earned 100 total points
ID: 7993965
Do you mean this?


while not oRS.EOF
  'work with your RS here
  ors.movenext
wend
0
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 100 total points
ID: 7994070
or:
with oRS
  do while not .EOF
    'work on the recordset
    .MoveNext
  Loop
End With

the While...Wend   is an OLD form of the loop structure, that is SUPPORTED in VB 6, but NOT in .NET.

The more modern form is as shown

there are several variations, as well:
(As shown above, the condition is evaluated BEFORE each pass through the loop, so the loop may, under some conditions NEVER actually be executed (the desired case for this example - id oRS is intially empty, thus initially at EOF))

or:

with oRS
  do
    'work on the recordset
    .MoveNext
  Loop While Not .EOF
End With

which will run through the LOOP AT LEAST once, even if the  condition is initially false (not advisable here)


or:

with oRS
  do UNTIL .EOF
    'work on the recordset
    .MoveNext
  Loop
End With

or:

with oRS
  do
    'work on the recordset
    .MoveNext
  Loop UNTIL .EOF
End With


in the last two forms, 'UNTIL' is logically equivalent to 'WHILE NOT'

AW
0
 
LVL 11

Expert Comment

by:rdrunner
ID: 7995472
Didnt know it was unsupported in .NET ;) thanx for the info... Should slowly start to get rid of it then...


*mental note taken...*
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:xThorx
ID: 8025130
You can use of course the do while ... loop function. BUT this loop cost a lot of time. The fastest way to go trough each record is the FOR ... to ... Step ... Next function and a record.movenext.
0
 

Expert Comment

by:CleanupPing
ID: 8901313
countyworker:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8964065
Moderator, my recommended disposition is:

    Split points between: rdrunner and Arthur_Wood

DanRollins -- EE database cleanup volunteer
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

777 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