Code:
SELECT CDate(Format([Date_Time],"mm/dd/yyyy")) AS ShiftDate, Glassing_Yield.PN, Switch(TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(0,0,0) And TimeSerial(5,0,0),"3rd Shift",TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(5,30,0) And TimeSerial(14,0,0),"1st Shift ",TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(14,0,0) And TimeSerial(22,0,0),"2nd Shift",TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(22,0,0) And TimeSerial(0,0,0),"3rd Shift") AS WorkShift, [Start_Qty]-[End_Qty] AS [Reject Qty], [End_Qty]/[Start_Qty] AS [Reject Pct], Glassing_Yield.Start_Qty, Glassing_Yield.End_Qty, Glassing_Yield.Date_Time, QRY_opt_report_query.Evaporation_Lot, QRY_opt_report_query.Diffusion_Lot, Glassing_Yield.Operator, Glassing_Yield.Glassing_Lot, Glassing_Yield.Batch_No, Glassing_Yield.WO, Glassing_Yield.Glassing_MachineFROM QRY_opt_report_query INNER JOIN Glassing_Yield ON QRY_opt_report_query.work_order = Glassing_Yield.WO
WHERE (((Glassing_Yield.Date_Time) Is Not Null))
GROUP BY CDate(Format([Date_Time],"mm/dd/yyyy")), Glassing_Yield.PN, Switch(TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(0,0,0) And TimeSerial(5,0,0),"3rd Shift",TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(5,30,0) And TimeSerial(14,0,0),"1st Shift ",TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(14,0,0) And TimeSerial(22,0,0),"2nd Shift",TimeValue([glassing_yield].[Date_Time]) Between TimeSerial(22,0,0) And TimeSerial(0,0,0),"3rd Shift"), [Start_Qty]-[End_Qty], [End_Qty]/[Start_Qty], Glassing_Yield.Start_Qty, Glassing_Yield.End_Qty, Glassing_Yield.Date_Time, QRY_opt_report_query.Evaporation_Lot, QRY_opt_report_query.Diffusion_Lot, Glassing_Yield.Operator, Glassing_Yield.Glassing_Lot, Glassing_Yield.Batch_No, Glassing_Yield.WO, Glassing_Yield.Glassing_Machine
HAVING (((CDate(Format([Date_Time],"mm/dd/yyyy"))) Between [Forms]![frmShiftYieldByDateRange]![txtStartDate] And [Forms]![frmShiftYieldByDateRange]![txtEndDate]) AND ((Glassing_Yield.Start_Qty)<>0))
ORDER BY CDate(Format([Date_Time],"mm/dd/yyyy")) DESC;