I have inherited this DB and need to make changes.
The code below is summing warehouse production by Dept for me. It is selecting records from tblHistory and giving me a prior 12 week actuals which is then the goal for the week. Well I only need fully trained people included in the goal.
There is a field in tblHistory called 'Training' and i only want records with 'N' in that field.
I was going to insert a where statement into the following but don't know exactly where it would go.
Something like: WHERE tblHistory.Training = N
Would that do it?
DoCmd.RunSQL ("INSERT INTO tblDeptGoalSample ( WeekStartDate, WeekEndDate, DeptCode, DeptDescription, DeptHrs, DeptUnits, DeptCartons ) " & _
"SELECT CDate(#" & GoalWeek(x).StartDate & "#), " & _
"CDate(#" & GoalWeek(x).EndDate & "#), " & _
"FIRST(tblActiveJobCd.JobGrp), " & _
"FIRST(tblActiveJobCd.Description), " & _
"SUM(tblHistory.StdHrs) AS SumOfStdHrs, " & _
"SUM(tblHistory.TotalUnit) As SumOfTotalUnit, " & _
"SUM(tblHistory.TotalCtn) As SumOfTotalCtn " & _
"FROM tblHistory " & _
"INNER JOIN tblActiveJobCd ON tblActiveJobCd.JobCd = tblHistory.JobCd " & _
"WHERE EntryDate >= #" & GoalWeek(x).StartDate & "# " & _
"AND EntryDate <= #" & GoalWeek(x).EndDate & "# " & _
"GROUP BY tblHistory.JobCd " & _
"ORDER BY tblHistory.JobCd")
The code below is summing warehouse production by Dept for me. It is selecting records from tblHistory and giving me a prior 12 week actuals which is then the goal for the week. Well I only need fully trained people included in the goal.
There is a field in tblHistory called 'Training' and i only want records with 'N' in that field.
I was going to insert a where statement into the following but don't know exactly where it would go.
Something like: WHERE tblHistory.Training = N
Would that do it?
DoCmd.RunSQL ("INSERT INTO tblDeptGoalSample ( WeekStartDate, WeekEndDate, DeptCode, DeptDescription, DeptHrs, DeptUnits, DeptCartons ) " & _
"SELECT CDate(#" & GoalWeek(x).StartDate & "#), " & _
"CDate(#" & GoalWeek(x).EndDate & "#), " & _
"FIRST(tblActiveJobCd.JobGrp), " & _
"FIRST(tblActiveJobCd.Description), " & _
"SUM(tblHistory.StdHrs) AS SumOfStdHrs, " & _
"SUM(tblHistory.TotalUnit) As SumOfTotalUnit, " & _
"SUM(tblHistory.TotalCtn) As SumOfTotalCtn " & _
"FROM tblHistory " & _
"INNER JOIN tblActiveJobCd ON tblActiveJobCd.JobCd = tblHistory.JobCd " & _
"WHERE EntryDate >= #" & GoalWeek(x).StartDate & "# " & _
"AND EntryDate <= #" & GoalWeek(x).EndDate & "# " & _
"GROUP BY tblHistory.JobCd " & _
"ORDER BY tblHistory.JobCd")