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

crystal reports 9 last record adds again in group 2

Status
Not open for further replies.

taterday

Programmer
Jan 28, 2009
183
0
0
US
This should be nothing for someone to answer.
There is no subreport. This report is a main report only.
I have group by employee. I want the cost rate for each hour work. This depends on the type of job this employee does.

example
Employee cost when training may be charged off at $25.00 an hour but while working with a customer may be charged off at $45.00 an hour. The running total feature can not be used.

I created a variable. This varible is in detail section. Normally I would suppress this. For auditing, I can see it is getting the right answer, (no extra calc) but when it prints in the group, the last calculation is added into the calc again.
//cost
whileprintingrecords;
currencyvar costrate;
costrate:= costrate + ({tentry.EMHours} * {tentry.EMCostRate})

I tried creating a print only variable and put in the group section. The last record is now in the total when it prints whether I have the p_cost in the group.

//p_cost
whileprintingrecords;
currencyvar costrate

I have a reset variable. I have moved it to the group header, group footer and nothing seem to work for me. I have added Whileprintingrecords; to this.

currencyvar costrate;
costrate:=0

Thank you for your support and help.

 
When you added the {@p_cost} formula to the Group Footer, you also need to remove the {@Cost} formula from the Group Footer, ie the {@Cost} formula should appear in the details section only.

Cheers
Pete
 
Thanks Pete, I still need help. I have done totals before without a problem.

I have the cost variable only in the detail.

It is the reset of the "costrate" variable that I seem to be having problems with. When I print the details, the sum prints as it accumulates in the costrate. It has the correct total. When the {@p_cost} prints it has the calc for the last record again (doubles) in it.

//cost_reset
currencyvar costrate;
costrate:=0

 
The reset formula should be in the Group Header (if you have more than one Group, the one that corresponds to the GF in which you want to display the total).

As long as {@Cost} has been added only to the Details section (and only once) and {@p_cost} has been added to the Group Footer section, it should work.

However, from what I can see, there doesn't appear to be any need to use variables. Why wouldn't you create a formula that calculates the Cost Rate (ie, {tentry.EMHours} * {tentry.EMCostRate}) and then use a simple Summary to create the totals.

Cheers
Pete
 
I did the simple summary because the rate varies and so does the hours worked using that rate.

I don't know how to trouble shoot my problem. I have the reset in the group heading that corresponds with the group footer that my p_cost is in. I know in my head it should be working, however, I dumped the data with SQL and put it in an excel spreadsheet. I know that CR is adding the last record twice.

Any suggestions.
 
I think you must have the cost formula in the group footer, too. Try removing the three formulas and make sure they have no check mark next to them in the field explorer, and then add them back to the correct sections.

-LB
 
I had a calc in the footer using the cost variable. When I removed it, the answer was there. I would not have thought that was the problem. I will note this in the CR book.

Thank you guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top