Hi,
I have an overtime formula that has been working but have a new requirement that needs to be factored into it.
There is a subreport variable (regprior) that is coming back to the main report that needs to be the starting value for the variable called reg2.
You'll see that reg2 is the running total as each detail line item is evaluated. By adding regprior as I have below it is adding the regprior value every time the each detail record is evaluated. I only want regprior added once. Whether regprior is included in the formula is dependent on the date on the detail record. The detail records are grouped in by the week beginning sunday. Sometimes regprior applies to the first group and sometimes not depending on all of the values in play. It's based on the date values in the detail section.
So, how do I start reg2 off with the regprior value and not have it added it again on each detail record evaluation? I'm thinking if I can isolate the first record that will do the trick. How do I identify the first detail record in crystal reports?
WhilePrintingRecords;
numbervar reg2;
numbervar ot;
numbervar temp;
numbervar regprior;
if reg2 <= 40 and ot = 0 then //check if the 40 hr threshold has been reached and also check if OT has been derived
(
reg2 := reg2 + {Command.quantity} + regprior;
if reg2 > 40 then
(
temp := reg2;
ot := temp - 40; //This is where the first OT hours are derived
)
)
else
(
//ot := ot + {Command.quantity}; //Running total to find total OT hrs
{Command.quantity}; //Display the OT hours from the formula
)
thanks!
Mark