I hate to rain on your parade, but the removesummaries statement absolutely does not care whether data records are visible or not when it is run. The code in question is only a dozen lines. It looks at every record in the database, whether it is visible or not, and removes that record if it is a summary record. If the record is a data record, it is ignored.
Just in case I was missing something obvious in that dozen lines of code, I made a loop and ran it 625 times (first 25 times, then 100, then 500). It worked perfectly every time, no problem. Here’s the code I ran on a checkbook database.
for n,1,500
statusmessage n
shortcall summarytest
endloop
return
summarytest:
field Date
groupup by month
field Debit
total
outlinelevel 1
removesummaries 7
return
I did have a thought – what if your code had de-selected the summary records? So I made a slight change. After making the summary records, I deselected all of the data records.
summarytest:
field Date
groupup by month
field Debit
total
outlinelevel 1
select info("summary")>0
removesummaries 7
return
The removesummaries statement did the correct thing – it noticed that there were no visible records so it automatically did a select all after removing all of the summary records. Again, I could loop as many times as I wanted with no problem.
Obviously if you are encountering crashes then something is wrong. However, there must be some additional factor beyond the outlinelevel statement. If you are using any form windows, I would see if the problem goes away when using only the data sheet.
I’m assuming that there is no corruption in your actual data. If there is, that of course could be the source of the problem and that would be why I can’t see the same problem here. To catch that sort of problem, the next beta version of Panorama automatically checks the integrity of the data each time the database is opened and saved.