Print Page | Close Window

Limit Subreport to 5 results? Newb using V 8.5

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=8822
Printed Date: 05 May 2024 at 8:04am


Topic: Limit Subreport to 5 results? Newb using V 8.5
Posted By: LNZPTI
Subject: Limit Subreport to 5 results? Newb using V 8.5
Date Posted: 06 Jan 2010 at 5:56pm
First off, I'm a total newb to crystal but was asked by the owner of my company to edit a report because I "know a lot about computers". We're still running version 8.5 and I was handed a book for version 7 and told to figure it out.

My company keeps records of every quote a salesman gives on an item in our inventory. I have a report created that I run daily for sales meetings that shows every inventory item quoted that day, and then a subreport that lists the entire quote history for that item. What I need it to do is display the results of the quote history subreport to whatever the last five quotes for that item were and then suppress the rest of the results. I need it to go back through our entire history, so limiting by date or anything like that doesn't really help me.

Is anyone feeling generous enough to point me in the right direction? I'm feeling pretty frustrated at the moment. Thanks.



Replies:
Posted By: hilfy
Date Posted: 07 Jan 2010 at 10:34am
I don't remember if 8.5 had "Running Totals" and I don't have a copy of it I can look at.  So here's two different ways of doing this:
 
If 8.5 does have Running Total, create one that will count the number of records - I'll call it {#RecCount}.  Then, in the Section Expert (right-click on the gray area to the left of the sections and it should be an option on the menu) DO NOT check the Suppress check box but click on the button to the right of Suppress.  Enter the following:  {#RecCount} > 5.
 
If it does not have running totals, you'll need to use a variable and a formula.  I'll call the formula mailto:%7b@RecCount - {@RecCount } and it will look like this:
 
NumberVar RecCount;
If PreviousIsNull({table.some identifying field}) then RecCount := 1
else RecCount := RecCount + 1;
RecCount
 
Note where the semi-colons are and that there is NOT one on the last line!  Also, you may have to put WhilePrintingRecords; as the first line in the formula to get it to work.  Then you'll do the same thing in the suppression formula as I outlined above:  mailto:%7b@RecCount - {@RecCount } > 5.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: LNZPTI
Date Posted: 07 Jan 2010 at 4:50pm
Fortunately, 8.5 does have the "running totals" option. This worked perfectly. Thank you so much!!!



Print Page | Close Window