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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't total values in detail section...

Status
Not open for further replies.

JMcVeigh

Instructor
Mar 27, 2003
21
0
0
US
I have a view that holds the data per student per class that has attended a course.
We charge a different rate for the first person than we do for the 2nd, 3rd, 4th and so on.
The first person registered is at full price, but each additional student is 30% of the full value per class.
So, what I did was to create a running total for each student(grouped by class offering and then by customer) and then created a formula that says if the running total (which is a count of the student name field in these groups) = 1 then 'full price' if not, then full price * .30
So, I can see the correct value in the detail section we are charging to the customer, but what I need is to total these values (which are stored in the details section), but I can't.
I think, logically, I understand why - because the running total is showing AFTER it needs to be calculated...so, my question is how can I get a grand total and/or subtotal for my two groups on this new cost field?
Any help/guidance is much appreciated.
Thanks
Jeanette
 
As well as running totals, there are summary totals. These are less flexible but are calculated before the group is printed. To get to them in Crystal 8.5, right-click and choose [Insert] and [Summary]. This should get round your problem.

Madawc Williams
East Anglia, Great Britain
 
Thanks for the suggestion, but when I right click on the formula that calculates the price per student, the option to Insert is not available (I am using 8.5).
Even if I don't choose the field and go through the menu options, the formula field is not available to use for the summary and/or subtotal options.

 
Could you set them all to 'full price * .30' and then add in a single instance of 'full price * .70' at the end?

It does require you to handle a no students case, but that is trivial.

Scotto the Unwise
 
Summary totals apply to database fields. I think you'd need to accumulate and then calculate.

Madawc Williams
East Anglia, Great Britain
 
You can create your totals manually as you go...

In the group header band of any groups that you want subtotals for insert a formula:

@Initialize
whileprintingrecords;

numbervar MyTotal;

MyTotal := 0;

In the details section, increment any running total variables:

@Accumulate
whileprintingrecords;

numbervar MyTotal;

if MyRunningTotal = 1 then
MyTotal := MyTotal + FullPrice
else
MyTotal := MyTotal + (FullPrice * .3)

Then you can create a display formula to display your total:

@Display
whileprintingrecords;

numbervar MyTotal;

MyTotal;

If you need Grand Totals then you can initialize a GrandTotal counter in the report header and accumulate that at the same time you accumulate the Group Totals.

-Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top