View Full Version : Report Sort Order


Mac_Wood
11-19-2006, 08:56 AM
Hi,

I have a report which group results by month, the query initially displays results in the correct month order i.e Jan,Feb,Mar.... and so on to Dec but when the report displays the results the months are listed in alphabetical order. When I return to the query results they also are now listed in alphabetical order. What do I need to do to have the report list them in "correct" month order? Also the results are for 2005 and 2006, what criteria expression do I need to use to filter the records to display only 2006 records?
Thanks in advance for your help

Brianwarnock
11-19-2006, 10:01 AM
You need to use 2 more calculated fields in your query, which need not be shown.

Month(yourfatefield) for the sort, this sorts on the numeric month number

and Year(yourdatefield) for the criteria

rian

Mac_Wood
11-20-2006, 12:49 PM
Thanks Brian. I already have one field calculation as follows

Year([AWB].[ShipmentPickedUpAT])*12+DatePart('m',[AWB].[ShipmentPickedUpAT])-1

Do I need to use 2 further calculated fields as detailed in your reply? If so do I just use them as you've written them or do I need to add anything?

Brianwarnock
11-21-2006, 01:55 AM
Yes you need the 2 fields as shown, I assume [AWB].[ShipmentPickedUpAT] is your date field

Month([AWB].[ShipmentPickedUpAT]) will produce the numeric number for the month and thus can be sorted as required

and Year([AWB].[ShipmentPickedUpAT]) will produce the Year for the criteria eg put 2006 in the criteria row.


Brian

Rich
11-21-2006, 02:24 PM
Thanks Brian. I already have one field calculation as follows

Year([AWB].[ShipmentPickedUpAT])*12+DatePart('m',[AWB].[ShipmentPickedUpAT])-1

Do I need to use 2 further calculated fields as detailed in your reply? If so do I just use them as you've written them or do I need to add anything?
Your existing calculated field will already sort correctly, add it to the report as a hidden control and use the Sort/Group button on the Reports toolbar to order the Report.