Loop through recordset with a twist

Q

QB

Hi I need to loop through a recordset, but in batch where I need to define a
start recordnumber and an end record number.

Basically, I have 32000, or so records, and I need to run code to loop
through the recordset 500 records at a time.

Click a button, run record 1 to 500
Change my code (start and end - could be pulled from a form control...)
Click a button, run record 501 to 1000
....

I started with the stardard code

iStart = 503
iEnd = 990
If rs.RecordCount > 0 Then
With rs
.MoveLast
iRecCount = .RecordCount
iCount = 0 + iStart
.Move iStart
Do While Not .EOF
iCount = iCount + 1
Status ("Processing Record: " & iCount & " of " & iRecCount)

.MoveNext
Loop
End With
End If


but now don't know how to mod the 'Do While Not .EOF' line. How do I check
which record I am currently accessing??

Thank you for the insight,

QB
 
J

John Spencer MVP

Perhaps what you want is

Do While Not .EOF and ICount <= iEnd

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
J

John Spencer MVP

Perhaps what you want is

Do While Not .EOF and ICount <= iEnd

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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