Looping

  • Thread starter Thread starter tcb
  • Start date Start date
T

tcb

I need to do something to a maximum of 1,000 records at a time.

How do I go through a recordset (in this example 3,789 records) to:

Do Something to each record in the groups of 1,000
Do Something to each record in the last group of 789

Without repeating any of my Do Something?

Thank you.
 
Dim objRS As Recordset
Dim intCount As Integer

intCount = 0
Do Until objRS.EOF
intCount = intCount + 1
If intCount < 1001 Then
' Do stuff
objRS.MoveNext
Else
' Start over. Don't move to next record.
intCount = 0
End If
Loop
 
Or:

Dim objRS As Recordset
Dim intCount As Integer

intCount = 0
Do Until objRS.EOF
intCount = intCount + 1
intCount = intCount Mod 1000
' Do stuff
objRS.MoveNext
Loop
 

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

Back
Top