D
Deb
Karl:
The way this is working now, the query is pulling all "Shipping Priority"
information from the tbl_History table. Here is the code for the Crosstab
query:
TRANSFORM Sum(tbl_History.DRMOTrans) AS DRMO
SELECT tbl_History.Division, tbl_History.Program
FROM tbl_History
GROUP BY tbl_History.Division, tbl_History.Program
PIVOT tbl_History.ShippingPriority;
That is working as expected. The current code for the query that is giving
me so many problems is:
SELECT ctqry_MthDrmPriority.Division, ctqry_MthDrmPriority.Program,
sqry_MonthlyRpt.TransactionDate, ctqry_MthDrmPriority.[1],
ctqry_MthDrmPriority.[2], ctqry_MthDrmPriority.[3],
ctqry_MthDrmPriority.CASREP, ctqry_MthDrmPriority.DTO,
Sum(sqry_MonthlyRpt.UnitCost) AS SumOfUnitCost
FROM ctqry_MthDrmPriority INNER JOIN sqry_MonthlyRpt ON
(ctqry_MthDrmPriority.Division = sqry_MonthlyRpt.Division) AND
(ctqry_MthDrmPriority.Program = sqry_MonthlyRpt.Program)
GROUP BY ctqry_MthDrmPriority.Division, ctqry_MthDrmPriority.Program,
sqry_MonthlyRpt.TransactionDate, ctqry_MthDrmPriority.[1],
ctqry_MthDrmPriority.[2], ctqry_MthDrmPriority.[3],
ctqry_MthDrmPriority.CASREP, ctqry_MthDrmPriority.DTO
HAVING (((ctqry_MthDrmPriority.[1]) Is Not Null)) OR
(((ctqry_MthDrmPriority.[2]) Is Not Null)) OR (((ctqry_MthDrmPriority.[3]) Is
Not Null)) OR (((ctqry_MthDrmPriority.CASREP) Is Not Null)) OR
(((ctqry_MthDrmPriority.DTO) Is Not Null))
ORDER BY ctqry_MthDrmPriority.Division, ctqry_MthDrmPriority.Program;
As you can see, I added the "Inner Join" that you suggested. The problem is
that, while the crosstab query works great on it's own, when I run the query
to add Unit Cost and Transaction date, the resulting query includes "Shipping
Priority" information that is contained in a separate column in tbl_History,
a column not included in the crosstab query. Shipping Priority information
is entered in either the "DRMO" field OR the "Shipped" field. I need the
query to pull only the information in the DRMO field which is correctly
displayed in the crosstab query.
The way this is working now, the query is pulling all "Shipping Priority"
information from the tbl_History table. Here is the code for the Crosstab
query:
TRANSFORM Sum(tbl_History.DRMOTrans) AS DRMO
SELECT tbl_History.Division, tbl_History.Program
FROM tbl_History
GROUP BY tbl_History.Division, tbl_History.Program
PIVOT tbl_History.ShippingPriority;
That is working as expected. The current code for the query that is giving
me so many problems is:
SELECT ctqry_MthDrmPriority.Division, ctqry_MthDrmPriority.Program,
sqry_MonthlyRpt.TransactionDate, ctqry_MthDrmPriority.[1],
ctqry_MthDrmPriority.[2], ctqry_MthDrmPriority.[3],
ctqry_MthDrmPriority.CASREP, ctqry_MthDrmPriority.DTO,
Sum(sqry_MonthlyRpt.UnitCost) AS SumOfUnitCost
FROM ctqry_MthDrmPriority INNER JOIN sqry_MonthlyRpt ON
(ctqry_MthDrmPriority.Division = sqry_MonthlyRpt.Division) AND
(ctqry_MthDrmPriority.Program = sqry_MonthlyRpt.Program)
GROUP BY ctqry_MthDrmPriority.Division, ctqry_MthDrmPriority.Program,
sqry_MonthlyRpt.TransactionDate, ctqry_MthDrmPriority.[1],
ctqry_MthDrmPriority.[2], ctqry_MthDrmPriority.[3],
ctqry_MthDrmPriority.CASREP, ctqry_MthDrmPriority.DTO
HAVING (((ctqry_MthDrmPriority.[1]) Is Not Null)) OR
(((ctqry_MthDrmPriority.[2]) Is Not Null)) OR (((ctqry_MthDrmPriority.[3]) Is
Not Null)) OR (((ctqry_MthDrmPriority.CASREP) Is Not Null)) OR
(((ctqry_MthDrmPriority.DTO) Is Not Null))
ORDER BY ctqry_MthDrmPriority.Division, ctqry_MthDrmPriority.Program;
As you can see, I added the "Inner Join" that you suggested. The problem is
that, while the crosstab query works great on it's own, when I run the query
to add Unit Cost and Transaction date, the resulting query includes "Shipping
Priority" information that is contained in a separate column in tbl_History,
a column not included in the crosstab query. Shipping Priority information
is entered in either the "DRMO" field OR the "Shipped" field. I need the
query to pull only the information in the DRMO field which is correctly
displayed in the crosstab query.