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

how to intialize variables

Status
Not open for further replies.

cancer2006

Programmer
Aug 25, 2006
45
US
I am using CRW8.5 and Access97. I have to calculate the number of active and terminated employees in different dpeartments. I am able to group the report by department, which is simple. I am not able to initialize the variables before the next department and as a result the variable increments untill the end of records. I placed the initialize formula in the group header but it is not working.

I have used the whileprintingrecords, it is not working either. I have tried different evaluation time but not working.

I am not clear on which different passes the formulas are calculated. So any help will be appreciated. Thanks.

Formula to calculate active employees, placed in group footer{
global numbervar DeptAcEmp;
if StrCmp ({tempTurnOver.empStatus},"A" ) = 0 then
DeptAcEmp := DeptAcEmp + 1;
DeptAcEmp;}

Formula to initialize variables, placed in group header{
global numbervar DeptAcEmp := 0;
global numbervar DeptTermEmp := 0;
}


Please see the sample output below. Thanks.


>First Group<
075904 Marketing/Hourly << Header >>
075904 10494 Gerhard Richard A
075904 10502 Braden Richard A
075904 10506 Bratek Adam A
075904 10507 Darnley Scott A
075904 10513 Mennucci Eli T
075904 10519 Gibson Gillis T

075904 6 Number of A's is 4.00 << Footer>>
Number of T's is 2.00
>2nd Group<
075905 Director Of Marketing Salaried << Header >>
075905 10448 Jay Stephen A

075905 1 Number of A's is 5.00 << Footer>>
Number of T'is 2.00
 
What we need to see is example data and the expected output, not formulas that don't work and bad output.

Try this:

Group header formula:
whileprintingrecords;
numbervar DeptAcEmp := 0;

details section formula
whileprintingrecords;
numbervar DeptAcEmp;
if {tempTurnOver.empStatus}= "A" then
DeptAcEmp := DeptAcEmp + 1;
//you can suppress the details formula

Then place this in the group footer for display:
whileprintingrecords;
numbervar DeptAcEmp;

-k
 
You could also rewrite it using Running Totals, which do a lot of the work for you.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thanks Madwac


I tried your formulas, that worked and after that I alos played around with running totals. I figures out running totals will do the same calculations much easily.

Initially, I just could not figure out how I could use the running total values in the formula.
Thanks for help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top