davesmith202
Employee of Access World
- Local time
- Today, 09:45
- Joined
- Jul 20, 2001
- Messages
- 522
I have a couple of nested loops as follows:
The code cycles through fine if the batch size divides nicely into the length of myarr2. But when it doesn't, I get a "Subscript out of range" error. Looks like when it looks at myarr2(intBatch), if the value of intBatch is higher than the array size, it fails.
How can I modify the inner loop so that it only cycles through enough times without going beyond the array size?
Thanks,
Dave
Code:
For i = 0 To UBound(myarr2)
'Loads of other code...etc etc
For intBatch = i To i + Me.ContentGroupSize - 1
myText=myText & myarr2(intBatch)
Next intBatch
i = i + Me.ContentGroupSize - 1
Next i
The code cycles through fine if the batch size divides nicely into the length of myarr2. But when it doesn't, I get a "Subscript out of range" error. Looks like when it looks at myarr2(intBatch), if the value of intBatch is higher than the array size, it fails.
How can I modify the inner loop so that it only cycles through enough times without going beyond the array size?
Thanks,
Dave