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

adding within an IF

Status
Not open for further replies.

soonerman1978

Programmer
Jun 26, 2003
8
US
I am trying to do an IF on a column in a database. Basically, it is checking to see if there is a "Work Order Number" that is equal to a particular "Work Center". Then, if there is a "Work Order Number" there and a corresponding "Work Center", it needs to add the "Employee Hrs" and the "Supervisor Hrs" for that record. For some reason, all that I am getting in return is the "Employee Hrs". Below is the Fields and values in the database and the CR formulas I have tried.

------------------
Database:
WorkOrderNumber | WorkCenter | SupervisorHrs | EmployeeHrs
03-C002 ProjManager 10.00 11.00

------------------

Formulas:
1. if {ManHours.WorkCenter} = "ProjManager" then {ManHours.EmployeeHrs} + {ManHours.SupervisorHrs} else 0.00

2. IIF ({ManHours.TimeWorkCenter} = "ProjManager",{ManHours.EmployeeHrs} + {ManHours.SupervisorHrs}, 0.00 )

3. IIF ({ManHours.TimeWorkCenter} = "Project Managers",{EmpandSup}, 0.00 )

Note: In 3., {EmpandSup} = {ManHours.EmployeeHrs} + {ManHours.SupervisorHrs}
-----------------------

Any help on this would be very much appreciated. Thanks.....
 
Try:

if rtrim({ManHours.WorkCenter}) = "ProjManager" then {ManHours.EmployeeHrs} + {ManHours.SupervisorHrs}
else
0

Now place this formula in the details section. Alongside place the {ManHours.WorkCenter} field so that you can determine which rows contain this.

You can also limit the rows returned by the database by using Report->Edit Selection Formula->Record and placing:

trim({ManHours.WorkCenter}) = "ProjManager"

If you don't get any rows, then you probably have the criteria wrong.

-k
 
I noticed in your formulas you referred to "timeworkcenter" in the last 2 formulas, but there is no field called that in your report layout.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top