>Hi all to the the good people of Universalthread:
> I have a problem that is driving me mad. I am trying to calcualate the values of total hours depending on the type of job in my cursor. Fox example, if job is "Labor" then calculate the total hours for Labor and so on. I want to place the value of total hours at the header level. What I did was to create a variable call nHours in the report variable and store creport.hours in the nHours and selected Sum option from calculate box. In the printwhen section I enter :
>
>IIF(Between(creport.type,1,2),sum(nhours),0) && (1..2 is labor)
>The result that I get is zero. Now I know this is not true. What can I do to accomplish the output that I want.
>
>Thanks alot
>MA
Two things ...
1 - If you want the sum in the HEADER you will have to process the data prior to running the report and figure out the totals and save them in a cursor. Then when running the report, the total will be available at the beginning of the header.
2 - If you can accept putting the totals in the FOOTER, then here's what you should do. Create some report variables to hold the various different totals (e.g., nLabor, nMaterial, etc.). In the expression of those report variables, place the following code:
Labor -- (assumes types 1 and 2 are labor)
IIF(BETWEEN(type,1,2), hours, 0)
Material -- (assumes types 3 and 4 are material)
IIF(BETWEEN(type,3,4), hours, 0)
Make sure the "Calculate" is set to NONE for each of these variables. Now, in the FOOTER, add the field object and put "nLabor" as the expression and mark the "calculate" function as SUM. Then do the same for nMaterial and any other types you have on your report.
Hope this helps,
Cathy