Nested Loops

W

Winger

I'm having problems with Nesting loops and wonder if there is something I
should know. I hav'ent programmed for 20 years and am trying to get back into
it with an Access VBA project.

In summary:-

While not RecordSet1.EOF
(Do Code)
While not RecordSet2.EOF
(Do more code)
RecordSet2.MoveNext
Wend
(Do some code before exisiting
RecordSet1.MoveNext
Wend

I'm guessing that I can nest two "While" Loops?.
Should I "mix and match" i.e. nest a Do loop around a While Loop?

The problem is I either get the results I require, or I get an error message
"Either BOF or EOF is true, or the record has been deleted".

I know the record hasn't been deleted - how to I check that BOF or EOF isn't
true before I exectute my code?


Any pointers greatly received.
 
O

Ofer

First there is no problem to nest two "While" Loops.
Second to check if there is date return in the recordsource, you should write
If MyRec.eof then
No data
end if
But you dont need to add that to your code, because the while loop will take
care of it, if there is no data, it wont access the loop.
To check how your code run by moving one step at a time, put the mouse in
the first line in the code, and press F9, it will put a code break in it,
when you run the code it will stop there, then by pressing the F8 key, you
can step one line a time, and see what happen, if it get in the loop or not.

If you need more help, please post the full code, we might see something
that might cose the code not to run.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

stuck in a loop 5
Compile Error ?? 0
Compile Error ?? 2
Do until Loop question 3
next without for error - stumped 3
Loop through Table records 7
Loop through recordset with a twist 1
Loop without Do 3

Top