I currently have a database that generates a dynamic report based on the dates they select as well as the class_id. To generate the report I use a crosstab query. The crosstab query is based on a query with the following fields: CCUST_ID, WEDate, Item_Type, Quantity, DESCRIPTION, Class_Type, Sort_Order
This generates a report with:
Cust ID(Group)
WE Date, Item1, Item2, Item3....etc
The data is in two tables:
Table - Item_Types: ITEM, MULTIPLE, INTERVAL, DESCRIPTION, Class_Type, Sort_Order
Table - Schedule: ID(autonumber), WEDate, Cust_ID, Item_Type, Quantity
I got everything to work except I can't figure out how to sort based on the sort order field. It automatically sorts it alphabetically, and that is not practical. I can't set the order manually because the fields change depending on the user input.
SQL of query below(the above examples were simplified to make easier reading)
Appreciate any help with this. Thanks.
PARAMETERS [Forms]![ReportSelector]![cmbType] Text ( 255 ), [Forms]![ReportSelector]![tStart] DateTime, [Forms]![ReportSelector]![tEnd] DateTime;
TRANSFORM Sum(qCust_Sched.Quantity) AS SumOfQuantity
SELECT qCust_Sched.CUST_ID, qCust_Sched.GROUP_DESC, qCust_Sched.CONTACT, qCust_Sched.PROJECT_TASK, qCust_Sched.LOCATION, qCust_Sched.TEL_NUMBER, qCust_Sched.SECT_CODE, qCust_Sched.WeekEndDate, Sum(qCust_Sched.Quantity) AS [Total Of Quantity]
FROM qCust_Sched
GROUP BY qCust_Sched.CUST_ID, qCust_Sched.GROUP_DESC, qCust_Sched.CONTACT, qCust_Sched.PROJECT_TASK, qCust_Sched.LOCATION, qCust_Sched.TEL_NUMBER, qCust_Sched.SECT_CODE, qCust_Sched.WeekEndDate
PIVOT qCust_Sched.Item_Type;
This generates a report with:
Cust ID(Group)
WE Date, Item1, Item2, Item3....etc
The data is in two tables:
Table - Item_Types: ITEM, MULTIPLE, INTERVAL, DESCRIPTION, Class_Type, Sort_Order
Table - Schedule: ID(autonumber), WEDate, Cust_ID, Item_Type, Quantity
I got everything to work except I can't figure out how to sort based on the sort order field. It automatically sorts it alphabetically, and that is not practical. I can't set the order manually because the fields change depending on the user input.
SQL of query below(the above examples were simplified to make easier reading)
Appreciate any help with this. Thanks.
PARAMETERS [Forms]![ReportSelector]![cmbType] Text ( 255 ), [Forms]![ReportSelector]![tStart] DateTime, [Forms]![ReportSelector]![tEnd] DateTime;
TRANSFORM Sum(qCust_Sched.Quantity) AS SumOfQuantity
SELECT qCust_Sched.CUST_ID, qCust_Sched.GROUP_DESC, qCust_Sched.CONTACT, qCust_Sched.PROJECT_TASK, qCust_Sched.LOCATION, qCust_Sched.TEL_NUMBER, qCust_Sched.SECT_CODE, qCust_Sched.WeekEndDate, Sum(qCust_Sched.Quantity) AS [Total Of Quantity]
FROM qCust_Sched
GROUP BY qCust_Sched.CUST_ID, qCust_Sched.GROUP_DESC, qCust_Sched.CONTACT, qCust_Sched.PROJECT_TASK, qCust_Sched.LOCATION, qCust_Sched.TEL_NUMBER, qCust_Sched.SECT_CODE, qCust_Sched.WeekEndDate
PIVOT qCust_Sched.Item_Type;