B
Bugs©
I've seen some of the posts here and tried Unions but it doesn't seem
to work for me. I've also seen comments as to "Why would you want a
query to have records that don't exist". So I'll to be as specific as
I can.
Let's say I have a table called Main that contains vehicles being made
with options and a report that shows the vehicles being made summed by
week. It's more complicated, I'm trying to simplify for posting.
tMain
Index - PKY (Auto Number)
Date (I've heard and will change name)
Product (Make of vehicle)
Plant (Location)
Option1 (Hrs to produce)
Option2 (Hrs to produce)
Option3 (Hrs to produce)
Option4 (Hrs to produce)
qM1_1 (consolidates makes)
SELECT tMain.Date, DatePart("ww",[Date]) AS Week, tMain.Product,
tMain.Plant, [Option1]+[Option3] AS OptionGroup1, [Option2]+[Option4]
AS OptionGroup2, Sum(tMain.Option1), Sum(tMain.Option2),
Sum(tMain.Option3), Sum(tMain.Option4)
FROM tMain
GROUP BY tMain.Date, DatePart("ww",[Date]), tMain.Product,
tMain.Plant, [Option1]+[Option3], [Option2]+[Option4]
HAVING (((tMain.Date)>=[Enter Beginning Date] And (tMain.Date)<=[Enter
Ending Date]) AND ((tMain.Product)="Make1");
qM1_2 (consolidates weeks production)
SELECT DISTINCTROW qM1_1.Week,
IIf(Weekday([Date],0)=0,[Date]+7,IIf(Weekday([Date],0)=1,[Date]+6,IIf(Weekday([Date],0)=2,[Date]+5,IIf(Weekday([Date],0)=3,[Date]+4,IIf(Weekday([Date],0)=4,[Date]+3,IIf(Weekday([Date],0)=5,[Date]+2,IIf(Weekday([Date],0)=6,[Date]+1,IIf(Weekday([Date],0)=7,[Date]+0))))))))
AS WeekEnding, qM1_1.Product, qM1_1.Plant, Sum(q1.OptionGroup1) AS
SumOfOptionGroup1, Sum(qM1_1.OptionGroup2) AS SumOfOptionGroup2,
FROM qM1_1
GROUP BY qM1_1.Week,
IIf(Weekday([Date],0)=0,[Date]+7,IIf(Weekday([Date],0)=1,[Date]+6,IIf(Weekday([Date],0)=2,[Date]+5,IIf(Weekday([Date],0)=3,[Date]+4,IIf(Weekday([Date],0)=4,[Date]+3,IIf(Weekday([Date],0)=5,[Date]+2,IIf(Weekday([Date],0)=6,[Date]+1,IIf(Weekday([Date],0)=7,[Date]+0)))))))),
qM1_1.Product, qM1_1.Plant;
qM1_3 (consolidates plants)
SELECT DISTINCTROW qM1_2.Week, qM1_2.WeekEnding, qM1_2.Product,
Sum(qM1_2.SumOfOptionGroup1) AS SumOfOptionGroup1,
Sum(qM1_2.SumOfOptionGroup2) AS SumOfOptionGroup2,
FROM qM1_2
GROUP BY qM1_2.Week, qM1_2.WeekEnding, qM1_2.Products;
Then more sets of queries for the other makes.
Report
SELECT qM1_3.WeekEnding, Avg(qM1_3.SumOfOptionGroup1) AS Make1OG1,
Avg(qM1_3.SumOfOptionGroup2) AS Make1OG2, Avg(qM2_3.SumOfOptionGroup1)
AS Make2OG1, Avg(qM2_3.SumOfOptionGroup2) AS Make2OG2,qM1_3,
Avg(qM3_3.SumOfOptionGroup1) AS Make3OG1, Avg(qM3_3.SumOfOptionGroup2)
AS Make3OG2,
[Enter Ending Date] AS EDate, [Enter Beginning Date] AS BDate
FROM qM1_3, qM2_3, qM3_3
GROUP BY qM1_3.WeekEnding, qM1_3.SumOfOptionGroup1,
qM1_3.SumOfOptionGroup2, qM2_3.SumOfOptionGroup1,
qM2_3.SumOfOptionGroup2, qM3_3.SumOfOptionGroup1,
qM3_3.SumOfOptionGroup2,, [Enter Ending Date], [Enter Beginning Date];
The report then displays the
Make1 Make2
Weekending OptionGoup1 OptionGroup2 OptionGroup1 OptionGroup2
mm/dd/yyyy nnn nnn nnn nnn
with each week ending having data. Sometimes, for example there might
not be any Make2's produced during a week but I need to have the
record.
Any help solving this would be greatly appreciated. I had thought of
simply adding a record for a day of the week for each make so that
there is data but then to multiply it by the plants is is a lot of
"fill".
Thanks in advance,
to work for me. I've also seen comments as to "Why would you want a
query to have records that don't exist". So I'll to be as specific as
I can.
Let's say I have a table called Main that contains vehicles being made
with options and a report that shows the vehicles being made summed by
week. It's more complicated, I'm trying to simplify for posting.
tMain
Index - PKY (Auto Number)
Date (I've heard and will change name)
Product (Make of vehicle)
Plant (Location)
Option1 (Hrs to produce)
Option2 (Hrs to produce)
Option3 (Hrs to produce)
Option4 (Hrs to produce)
qM1_1 (consolidates makes)
SELECT tMain.Date, DatePart("ww",[Date]) AS Week, tMain.Product,
tMain.Plant, [Option1]+[Option3] AS OptionGroup1, [Option2]+[Option4]
AS OptionGroup2, Sum(tMain.Option1), Sum(tMain.Option2),
Sum(tMain.Option3), Sum(tMain.Option4)
FROM tMain
GROUP BY tMain.Date, DatePart("ww",[Date]), tMain.Product,
tMain.Plant, [Option1]+[Option3], [Option2]+[Option4]
HAVING (((tMain.Date)>=[Enter Beginning Date] And (tMain.Date)<=[Enter
Ending Date]) AND ((tMain.Product)="Make1");
qM1_2 (consolidates weeks production)
SELECT DISTINCTROW qM1_1.Week,
IIf(Weekday([Date],0)=0,[Date]+7,IIf(Weekday([Date],0)=1,[Date]+6,IIf(Weekday([Date],0)=2,[Date]+5,IIf(Weekday([Date],0)=3,[Date]+4,IIf(Weekday([Date],0)=4,[Date]+3,IIf(Weekday([Date],0)=5,[Date]+2,IIf(Weekday([Date],0)=6,[Date]+1,IIf(Weekday([Date],0)=7,[Date]+0))))))))
AS WeekEnding, qM1_1.Product, qM1_1.Plant, Sum(q1.OptionGroup1) AS
SumOfOptionGroup1, Sum(qM1_1.OptionGroup2) AS SumOfOptionGroup2,
FROM qM1_1
GROUP BY qM1_1.Week,
IIf(Weekday([Date],0)=0,[Date]+7,IIf(Weekday([Date],0)=1,[Date]+6,IIf(Weekday([Date],0)=2,[Date]+5,IIf(Weekday([Date],0)=3,[Date]+4,IIf(Weekday([Date],0)=4,[Date]+3,IIf(Weekday([Date],0)=5,[Date]+2,IIf(Weekday([Date],0)=6,[Date]+1,IIf(Weekday([Date],0)=7,[Date]+0)))))))),
qM1_1.Product, qM1_1.Plant;
qM1_3 (consolidates plants)
SELECT DISTINCTROW qM1_2.Week, qM1_2.WeekEnding, qM1_2.Product,
Sum(qM1_2.SumOfOptionGroup1) AS SumOfOptionGroup1,
Sum(qM1_2.SumOfOptionGroup2) AS SumOfOptionGroup2,
FROM qM1_2
GROUP BY qM1_2.Week, qM1_2.WeekEnding, qM1_2.Products;
Then more sets of queries for the other makes.
Report
SELECT qM1_3.WeekEnding, Avg(qM1_3.SumOfOptionGroup1) AS Make1OG1,
Avg(qM1_3.SumOfOptionGroup2) AS Make1OG2, Avg(qM2_3.SumOfOptionGroup1)
AS Make2OG1, Avg(qM2_3.SumOfOptionGroup2) AS Make2OG2,qM1_3,
Avg(qM3_3.SumOfOptionGroup1) AS Make3OG1, Avg(qM3_3.SumOfOptionGroup2)
AS Make3OG2,
[Enter Ending Date] AS EDate, [Enter Beginning Date] AS BDate
FROM qM1_3, qM2_3, qM3_3
GROUP BY qM1_3.WeekEnding, qM1_3.SumOfOptionGroup1,
qM1_3.SumOfOptionGroup2, qM2_3.SumOfOptionGroup1,
qM2_3.SumOfOptionGroup2, qM3_3.SumOfOptionGroup1,
qM3_3.SumOfOptionGroup2,, [Enter Ending Date], [Enter Beginning Date];
The report then displays the
Make1 Make2
Weekending OptionGoup1 OptionGroup2 OptionGroup1 OptionGroup2
mm/dd/yyyy nnn nnn nnn nnn
with each week ending having data. Sometimes, for example there might
not be any Make2's produced during a week but I need to have the
record.
Any help solving this would be greatly appreciated. I had thought of
simply adding a record for a day of the week for each make so that
there is data but then to multiply it by the plants is is a lot of
"fill".
Thanks in advance,