Lawrence Mrazek
lmrazek at lcm-res.com
Wed Mar 23 16:16:18 CST 2005
Hi: I'm currently having a bit of problem creating a Crosstab query for a twelve month period, with the period starting from a user-selected value. Thus, if user selects a date in June 2004, I want the report to display data from June-2004 to May 2005 ... My current code is below. (I want to have static headings so I can bind the query to a report). TRANSFORM Sum(qryMonthlyProduction.SumOfBags) AS SumOfSumOfBags SELECT qryMonthlyProduction.ProductionFacility, qryMonthlyProduction.ProductionLine, qryMonthlyProduction.Shift, Sum(qryMonthlyProduction.SumOfBags) AS [Total Of SumOfBags] FROM qryMonthlyProduction GROUP BY qryMonthlyProduction.ProductionFacility, qryMonthlyProduction.ProductionLine, qryMonthlyProduction.Shift ORDER BY "Month" & DateDiff("m",[DateEntered],DateAdd("m",11,[Forms]![frmWeeklyReportCriteria]! [txtWeek])) PIVOT "Month" & DateDiff("m",[DateEntered],DateAdd("m",11,[Forms]![frmWeeklyReportCriteria]! [txtWeek])); When I run this, it displays the fields in the following order (I'd like the months to be arranged in order): Production Facility - ProductionLine - Shift - Total of SumOfBags - Month0 - Month1 - Month10 - Month11 - Month2 - Month3 ... Month9 Any hints? Thanks in advance! Larry Mrazek LCM Research, Inc. www.lcm-res.com lmrazek at lcm-res.com ph. 314-432-5886 fx. 314-432-3304