Results 1 to 2 of 2
  1. #1
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170

    Group By Hour, Avearge Multiple Shift Types within Hour

    Hi Folks,

    My current query is shown below, and it works great. Except for one fatal flaw.

    Operators are selecting Shift Type at irregular periods throughout the hour, which creates two goals for the hour, instead of just one. Is there anyway to embed an update query (or some other mechanism) that IF an operator selects "Break" or "Lunch" during that hour, it updates all the shift type fields to "Break" or "Lunch" ONLY for that hour? (So if the Operator selects "Break" under [Shift Type] at Hour 17, Hour 17 Shift Types get updated to "Break" and it does not run over into Hour 18)



    Date Operator Prod Hour Shift Type CountOfLID Goal Text15
    09/20/2013 John Smith 17 Break 3 26 12%
    09/20/2013 John Smith 17 Full Shift 13 35 37%


    Code:
    SELECT Format([Time Added],"mm/dd/yyyy") AS [Date], [D1-Prod-MainTable].Operator, Hour([Time Added]) AS [Prod Hour], [D1-Prod-MainTable].[Shift Type], Count([D1-Prod-MainTable].LID) AS CountOfLID, IIf([Shift Type]="Full Shift","35",IIf([Shift Type]="Break","26",IIf([Shift Type]="Lunch","18","35"))) AS Goal, DCount("[LID]","D1-Prod-MainTable","[LID]=" & [D1-Prod-MainTable].[LID])/[Goal] AS Expr1
    FROM [D1-Prod-MainTable]
    GROUP BY Format([Time Added],"mm/dd/yyyy"), [D1-Prod-MainTable].Operator, Hour([Time Added]), [D1-Prod-MainTable].[Shift Type], IIf([Shift Type]="Full Shift","35",IIf([Shift Type]="Break","26",IIf([Shift Type]="Lunch","18","35"))), DCount("[LID]","D1-Prod-MainTable","[LID]=" & [D1-Prod-MainTable].[LID])/[Goal]
    HAVING (((Format([Time Added],"mm/dd/yyyy"))>=Format([Forms]![D1-Reports]![DateStart],"mm/dd/yyyy") And (Format([Time Added],"mm/dd/yyyy"))<=Format([Forms]![D1-Reports]![DateTo],"mm/dd/yyyy")) AND (([D1-Prod-MainTable].Operator)=[Forms]![D1-Reports]![Operator]));

  2. #2
    mrojas is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    How do users select a Shift Type? Is there input form? How is it that selecting Break under one hour runs over into the next?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Time() and adding an hour in front or behind
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 08-22-2013, 06:01 PM
  2. Reset Combo Box to Default Value After One Hour
    By athyeh in forum Programming
    Replies: 3
    Last Post: 08-14-2013, 10:14 AM
  3. Rounding number up to half hour
    By crxftw in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:29 AM
  4. Time minus one for hour.
    By brianb in forum Queries
    Replies: 2
    Last Post: 03-09-2011, 11:02 AM
  5. Round up time half an hour
    By JBM18 in forum Queries
    Replies: 2
    Last Post: 12-09-2010, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums