A
AccessKay
I’m trying to find out how I can fix my query so that it doesn’t have records
with zero values. Karl Dewey helped me with a clever way to create a query
that pulls noncontiguous months for Labor_Cost totals. The criteria for the
query is selected from an unbound form with two text boxes. This query works
fine but then I needed to add some fields to it. I added fields, Category
and DGroup and it was okay but then I added Product and that’s when the lines
with zero totals showed up. It’s not for the same product. Here’s a visual
example:
Category DGroup Product Mo1 Mo2
Training Labor Prod1 $5,000 $6542
Develop Labor Prod25 $0 $0
Training Labor Prod7 $2395 $4598
There is no information for Prod25, so why does it appear in the query? I
tried to group it different ways but wasn’t able to get it to work. It's not
even in my table as a zero amount.
As always…I appreciate the help!
Note: I was a little confused about putting the IsNotNull And <>0 criteria
in the Where statement or the Having statement but got the same results.
My SQL is as follows:
SELECT tblTrans_Mstr.Category, tblTrans_Mstr.DGroup, tblTrans_Mstr.Product,
Sum(IIf([TransDate] Between CVDate([Forms]![frmDialogBox]![txtMo1]) And
DateAdd("m",1,CVDate([Forms]![frmDialogBox]![txtMo1]))-1,[tblTrans_Mstr].[Labor_Cost],0))
AS Month_1, Sum(IIf([TransDate] Between
CVDate([Forms]![frmDialogBox]![txtMo2]) And
DateAdd("m",1,CVDate([Forms]![frmDialogBox]![txtMo2]))-1,[tblTrans_Mstr].[Labor_Cost],0)) AS Month_2
FROM tblTrans_Mstr
WHERE (((tblTrans_Mstr.Labor_Cost) Is Not Null And
(tblTrans_Mstr.Labor_Cost)<>0))
GROUP BY tblTrans_Mstr.Category, tblTrans_Mstr.DGroup, tblTrans_Mstr.Product
HAVING (((tblTrans_Mstr.DGroup)="Labor"));
with zero values. Karl Dewey helped me with a clever way to create a query
that pulls noncontiguous months for Labor_Cost totals. The criteria for the
query is selected from an unbound form with two text boxes. This query works
fine but then I needed to add some fields to it. I added fields, Category
and DGroup and it was okay but then I added Product and that’s when the lines
with zero totals showed up. It’s not for the same product. Here’s a visual
example:
Category DGroup Product Mo1 Mo2
Training Labor Prod1 $5,000 $6542
Develop Labor Prod25 $0 $0
Training Labor Prod7 $2395 $4598
There is no information for Prod25, so why does it appear in the query? I
tried to group it different ways but wasn’t able to get it to work. It's not
even in my table as a zero amount.
As always…I appreciate the help!
Note: I was a little confused about putting the IsNotNull And <>0 criteria
in the Where statement or the Having statement but got the same results.
My SQL is as follows:
SELECT tblTrans_Mstr.Category, tblTrans_Mstr.DGroup, tblTrans_Mstr.Product,
Sum(IIf([TransDate] Between CVDate([Forms]![frmDialogBox]![txtMo1]) And
DateAdd("m",1,CVDate([Forms]![frmDialogBox]![txtMo1]))-1,[tblTrans_Mstr].[Labor_Cost],0))
AS Month_1, Sum(IIf([TransDate] Between
CVDate([Forms]![frmDialogBox]![txtMo2]) And
DateAdd("m",1,CVDate([Forms]![frmDialogBox]![txtMo2]))-1,[tblTrans_Mstr].[Labor_Cost],0)) AS Month_2
FROM tblTrans_Mstr
WHERE (((tblTrans_Mstr.Labor_Cost) Is Not Null And
(tblTrans_Mstr.Labor_Cost)<>0))
GROUP BY tblTrans_Mstr.Category, tblTrans_Mstr.DGroup, tblTrans_Mstr.Product
HAVING (((tblTrans_Mstr.DGroup)="Labor"));