Loop through continuous form

J

Jeff Hunt

Is there an easy way to loop through all the records on a continuous form? I
know how to set up a recordset, but I was hoping for something even more
straightforward/simple. Something like:

for each txtbox in form
....
next txtbox.

Just curious if anyone knows of something like this. Thx!
 
J

Jeff Boyce

Jeff

I'm confused...

"loop through all the records" implies a recordset. "for each textbox"
implies controls on a form.

What are you trying to do? (you described how you are trying to do
something, but not what)

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff Hunt

I haven't had much occasion to use FOR loops, so I'm not surprised I confused
you.

Say you have a continuous form that is based on a table and it is filtered
to a particular set of criteria. One thing I would like to be able to do is
make a corresponding record in another table for each record displayed on the
form. I've wanted to do this for other things, too, but this was the task I
was trying to do now which incited the question. In this case, there are
other criteria and calculations I am doing in code, so it is not practical to
just try to use an append query.

In the past, when I have had to do this, I have made a recordset so I can
append one record, do an rs.movenext and append the next record. Since I
already have a recordset of sorts by means of the continuous form, I was
hoping to find an easy way to reference each row on the form, in turn. Sorry
if my sample code was confusing, I meant to imply that txtbox was the name of
a specific control. In English, the loop I was intending was "start at the
first record on the continuous form. Using the value in text box ABC run
some code, then move to the next record and access the value in text box ABC
again."

Is that any clearer?
 
J

Jeff Boyce

Jeff

I suspect you are describing iterating through a recordset and creating a
new record (in Table2) for each qualifying record in the recordset.

I also suspect you could use a query and use functions to do the
calculations within the query, then append the results of that query to
Table2. If it makes it any easier, you could first create a query that
returns all the values you want, then create a second query based on the
first that does the append.

If you provide more specific description of what you think cannot be done in
a query, folks here may be able to offer more specific suggestions.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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