lopiteaux
Board Regular
- Joined
- Jun 8, 2011
- Messages
- 77
Hi all,
I have written a bit of code that cycles through tabled data and matches certain records with other records in the table. I start from the top using a For-Next loop and for every n in the first For-Next loop I run another loop on the same table in order to find the matching entry.
The code works perfectly, but there is one small problem - for some records I need to add an additional record in the dataset, thus increasing the size of the original dataset. I have added a line to increase the LastRow, which is the closing point for both For-Next loops, but the problem is that this does not update in the actual loop, so it still stops at the original LastRow (e.g. original LastRow was 500 and 50 rows were added by the code, resulting LastRow should be - and is - 550 but the loop still closes at 500).
Sorry for the lack of code - thought it would be unecessary given that the issue is pretty simple. I have obviously thought of switching the current For-Next loop for a Do Until loop, using IsEmpty(x) as the closing point, but I am rather partial to the For-Next structure, not to mention that I'm not that keen to rewrite it all now.
Would anyone be able to give me any insight into the above?
Regards,
l.
I have written a bit of code that cycles through tabled data and matches certain records with other records in the table. I start from the top using a For-Next loop and for every n in the first For-Next loop I run another loop on the same table in order to find the matching entry.
The code works perfectly, but there is one small problem - for some records I need to add an additional record in the dataset, thus increasing the size of the original dataset. I have added a line to increase the LastRow, which is the closing point for both For-Next loops, but the problem is that this does not update in the actual loop, so it still stops at the original LastRow (e.g. original LastRow was 500 and 50 rows were added by the code, resulting LastRow should be - and is - 550 but the loop still closes at 500).
Sorry for the lack of code - thought it would be unecessary given that the issue is pretty simple. I have obviously thought of switching the current For-Next loop for a Do Until loop, using IsEmpty(x) as the closing point, but I am rather partial to the For-Next structure, not to mention that I'm not that keen to rewrite it all now.
Would anyone be able to give me any insight into the above?
Regards,
l.