Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to limit the number of rows displayed?

Status
Not open for further replies.

numina

Programmer
Jan 28, 2002
12
US

Does anyone know how to display only the first, say, 7 records on a report?

Thanks!

numina
 
Use this steps: I brought my records by period of 8.

Step 1
create a formula in "report header"
WhilePrintingRecords;
numbervar ss:=-2;
ss

Step 2
Go to report section and select the details
make sure the option "new page before" is checked and enter the formula by clicking the button nexr to it.
Then type this formula
WhilePrintingRecords;
numbervar ss;
ss=7

Step 3

create a formula in "details"
WhilePrintingRecords;
numbervar ss;
ss:=ss+1;
if ss>7 then
ss:=0;
ss

That should solve your problem.But don't froget to supress your formulas in step 1 and step 3 .We don't want them to be displayed do we?

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 
Make it simple. If you are using CR V7 or newer, create a running total count field, evaluate on every record, reset=never.

Then, in the section expert, format the details section to suppress if {#count} is greater than 7.

If you are using groups, then modify your running total field to reset on change of group.

Please be advised that suppressing records will not keep them from evaluating in any sub or grand totals the report may have. If this is the case, create more running total field to only total if {#count} <=7. Software Support for Macola, Crystal Reports and Goldmine
dgillz@juno.com
 
If you're using SQL Server and write a stored procedure to be your data source:

a) V7 or higher
SELECT TOP 7 field1, ...

b) V6.5 or lower
SET ROWCOUNT 7
SELECT field1, ...

If you go with the suppressing records in the Crystal report itself, hopefully the report will not be selecting thousands of records only to display 7 because those thousands records will be pulled down to your PC anyway.
 
Balves you are right I misunderstood the question :=).
I thought the report would bring the records by n reocrds per page.

So your answer is right.Might I suggest using the syntax
fetch first n rows only if DB2 is used as a database. Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 

Just found out about another way of achieving this. You can use the following formula in the Section Expert Suppression option:

RecordNumber > 7

numina
 
But there is one thing you sholud consider.In both Balves's and my solutions we brought only n records which n is the number of records wanted.
If you have 10000 records and type recordnumber>7 your SQL will bring 10000 thus decreasing the overall performance of records.
Don't forget.Suppression only hides the fields from you.In fact all of the records are there. Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top