Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

question about do while loop?

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
countyworker
Asked:
countyworker
2 Solutions
 
rdrunnerCommented:
Do you mean this?


while not oRS.EOF
  'work with your RS here
  ors.movenext
wend
0
 
Arthur_WoodCommented:
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
 
rdrunnerCommented:
Didnt know it was unsupported in .NET ;) thanx for the info... Should slowly start to get rid of it then...


*mental note taken...*
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
xThorxCommented:
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
 
CleanupPingCommented:
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
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Split points between: rdrunner and Arthur_Wood

DanRollins -- EE database cleanup volunteer
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now