>>I am doing a report in which I want to list only the first 15 records in each grouping, not the whole file.
>>
>>I put in a counter and asked it to print when the counter is < 16, but it's printing the first 15 then leaving blank lines for all the rest (100's of blank pages). I have the no print when empty checked, but that doesn't do it.
>>
>>Is there a way to get it to quit after 15 and go to the next category?
>>
>>Thanks,
>>Rebecca
>
>I've had to do this for another client, but had a multi-part process... Like suggested, do a select group by, order by whatever your criteria calls for. Add an extra column to your select as a flag... ex: .F. as OkToShow...
>
>Then, once you have your cursor, you'll have to run it through a loop and set the flag on each group... something like...
>
>
>select distinct GroupFields from YourCursor into cursor C_MyScan
>
>select C_MyScan
>scan
> select YourCursor
> seek C_MyScan.GroupFields
> lnI = 0
> do while GroupFields = C_MyScan.GroupFields and lnI < 15
> replace OkToShow with .t.
You're right, it doesn't work to just get TOP 15, as it gets only the top 15 in the file. I will write code similar to what you have here to get the top 15 into a cursor. Like I said, I was trying to be lazy!!!
> skip
> endfor
>
> select C_MyScan
>endscan
>
>
>
>Finally, back at your cursor, build a filtered index on only the "OkToShow" records = .t., or re-select from YourCursor where OkToShow and use THAT cursor for the reporting.