Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do while loops 1

Status
Not open for further replies.

ferryjenny

Technical User
Nov 22, 2000
24
0
0
GB
I have two recordsets that I want to loop through at the same time. I have entered the code

Do while not DRS.Eof and not BRS.Eof


DRS.MoveNext
BRS.MoveNext
Loop

But it dosent seem to be looping. It just returns the first record of both recordsets.

Can anyone help
 
and you're sure given their queries that they both return more than one record? codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
One of the queries returns one record and the other returns three I want it to looop through them both until they both reach EOF.

If i cahnge the data so they both return the same amount of records then it works but I want them to be able t return different amounts of records
 
while not DRS.Eof or not BRS.Eof
if not DRS.eof then
'use DRS
DRS.MoveNext
end if
if not BRS.eof then
'use BRS
BRS.MoveNext
end if
wend codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
or:
Code:
Do While NOT DRS.Eof AND NOT BRS.Eof
  if not DRS.eof then
    'use DRS
    DRS.MoveNext
  end if
  if not BRS.eof then
    'use BRS
    BRS.MoveNext
  end if
wend
The problem here is that your not really getting any extra functionality by putting them both in the loop like this. I can't see why you would need to display the contents of both recordsets side by side when the data is unrelated, if this isn't the answer to your problem perhaps you could outline it a bit more in depth.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
actually i intentionally used OR so it would loop until BOTH recsets were eof - agree on the other tho - i'd have to consider it inefficient design 9 times out of 10 if the 2 recsets couldn't become 1 with bit if SQL magic codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
Actually, both statements were the same, I only switched it to a Do Loop because ferryjenny used that above, it wasn't a correction just another view of the same thing :)
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
*chuckle*
yours: Do While NOT DRS.Eof AND NOT BRS.Eof
mine: while not DRS.Eof or not BRS.Eof

note the OR vs the AND between the two .eof's codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
My mistake, mine will kick out when either is EOF, mis-calculated the double negative of EOF and NOT.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top