By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,454 Members | 3,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,454 IT Pros & Developers. It's quick & easy.

Exactly where is it that I get kicked out of a Do Until ... Loop while traversing records in DAO RecSet???

P: n/a
MLH
Take a look at the code that follows. Line 110 is the beginning
of Do-Loop. Regarding line #220, I find that I'm getting Error #3021
(No Current Record) during execution of line #230. It puzzles me
as to Why? I thought if I was on last valid record of RecSet when
line #220 executes, I would be sent to process lines after line #400.
Am I wrong about that?

==> BEGIN CODE SNIPPET <===
110 Do Until RecSet.EOF
StartAnew:
120 WhereAmI = "StartAnew"
....

190 i = i + 1
200 WhereAmI = "Point2"
AddStuff:
210 MyVar0 = MyVar0 & RecSet.TreeField & CRLF & CRLF
220 RecSet.MoveNext ' Kicked out-a-the-loop here???
230 MyVar1 = Trim$(CStr(RecSet.Cust_ID)) & RecSet.RName
....

380 Close #1 ' Close file.
390 ... more code ...
400 Loop
FinishTheLast:
410 WhereAmI = "FinishTheLast"
420 RecSet.MoveLast
430 MyVar2 = MyVar2 & RecSet.MyField
==> END CODE SNIPPET <===

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
It's not as though the code on line 110 sits in the background, waiting
until you hit EOF. It's not analogous to On Error GoTo..., if that's what
you're thinking.

Statement 110 only checks for EOF when it gets executed. In other words, the
only time that statement does anything is when the Loop statement on line
400 tells execution to return to line 110.

Every time you have a MoveNext statement, the very next statement must be a
check for EOF.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"MLH" <CR**@NorthState.net> wrote in message
news:t9********************************@4ax.com...
Take a look at the code that follows. Line 110 is the beginning
of Do-Loop. Regarding line #220, I find that I'm getting Error #3021
(No Current Record) during execution of line #230. It puzzles me
as to Why? I thought if I was on last valid record of RecSet when
line #220 executes, I would be sent to process lines after line #400.
Am I wrong about that?

==> BEGIN CODE SNIPPET <===
110 Do Until RecSet.EOF
StartAnew:
120 WhereAmI = "StartAnew"
...

190 i = i + 1
200 WhereAmI = "Point2"
AddStuff:
210 MyVar0 = MyVar0 & RecSet.TreeField & CRLF & CRLF
220 RecSet.MoveNext ' Kicked out-a-the-loop here???
230 MyVar1 = Trim$(CStr(RecSet.Cust_ID)) & RecSet.RName
...

380 Close #1 ' Close file.
390 ... more code ...
400 Loop
FinishTheLast:
410 WhereAmI = "FinishTheLast"
420 RecSet.MoveLast
430 MyVar2 = MyVar2 & RecSet.MyField
==> END CODE SNIPPET <===

Nov 12 '05 #2

P: n/a
MLH
Man, you have really cleared the air for me. I was assuming
the code in line #110 operated like On Error GoTo. You had
me pegged! Thx much for the explanation.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx
On Sun, 21 Sep 2003 18:01:08 GMT, "Douglas J. Steele"
<dj******@canada.com> wrote:
It's not as though the code on line 110 sits in the background, waiting
until you hit EOF. It's not analogous to On Error GoTo..., if that's what
you're thinking.

Statement 110 only checks for EOF when it gets executed. In other words, the
only time that statement does anything is when the Loop statement on line
400 tells execution to return to line 110.

Every time you have a MoveNext statement, the very next statement must be a
check for EOF.


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.