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

Access Calculation

Status
Not open for further replies.

mot98

MIS
Joined
Jan 25, 2002
Messages
647
Location
CA
Hi all,

I have an access query that is totaling hours worked grouped by day. I need to give a "Regular Hours Total" and an "Overtime Hours Total". I am trying to use the following syntax, but keep getting errors.


If Sum([Total Hours]) > 8 Then =8 Else =Sum([Total Hours])


Then for to calculate the overtime hours I am using this


If Sum([Total Hours]) > 8 Then =(Sum([Total Hours]) -8) Else = 0


Can someone tell me the correct syntax to get this to work.

Thanks,


mot98
[cheers]
"I'd rather be dead and cool..then alive and uncool."
---Harley Davidson & The Marlboro Man
 
Never mind...got it figured out.

Thanks...

mot98
[cheers]
"I'd rather be dead and cool..then alive and uncool."
---Harley Davidson & The Marlboro Man
 
This should do it for you.... to use a conditional statement in a query use the iif() function. More information can be found in help.

SELECT tblHours.WorkerID, IIf(Sum([TotalHours])>8,8,Sum([TotalHours])) AS Normal, IIf(Sum([TotalHours])>8,Sum([TotalHours])-1,0) AS Overtime
FROM tblHours
GROUP BY tblHours.WorkerID;

Hope that helps!
-Jim
 
guess I'm not quick enough. Glad you figured it out though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top