loop within a loop, sort of

D

Dap

I have a situation where a sub loops through a recordset
to perform calculations on each record through the use of
a public function. Within that recordset there is an
instance where the public funtion must use another loop to
search back again through the recordset to redo certain
calculations. My problem is I easily was able to have the
loop start with the first record in the recordset and
finish with the last in the sub, however, in the public
fundtion, I am not able to tell it anything more than
where to start (DoCmd.GotoRecord , , acFirst). How do I
tell the function to start the loop, and then end it when
there are no records left to look at anymore. I am
getting errors about objects and blocks. Please help if
you can or let me know if you need more information.
Thanks.
 
B

Bryan Reich [MSFT]

A better aproach would be to pass the record set in as an argument to the
function doing your calculations and if you need to go through the record
set in that calculation, clone the original record set (again, passed in as
an argument), and then iterate through that record set just as you are doing
in the main subroutine. Don't use GotoRecord, that actually moves the form
itself to the first record. You're just doing background recalculation,
correct?
Post back and let me know if you have any more questions.
 

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

Top