How to Create a Custom Sort Order for an Access Report
Question details
The user needs to establish a custom sort order for a report without encountering grouping conflicts in crosstab queries.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Designing a report based on a crosstab query where specific custom sorting is required but causes SQL clause conflicts.
- Observed behavior
- An ORDER BY and GROUP BY conflict is returned when the custom sorting expression is not included in the grouping.
Before modifying your queries, identify the specific fields you need to sort by and ensure no other database objects depend on the query's current sorting behavior.
Define Custom Order in Report Settings
Removing the ORDER BY clause from the query and managing the sorting directly in the report design prevents query conflicts.
The most straightforward way to avoid GROUP BY conflicts in crosstab queries is to delegate the sorting responsibility to the report itself. Access provides dedicated grouping and sorting features that override query-level ordering.
Open your crosstab query in Design View, locate the field with the sorting criteria, and remove the ORDER BY settings. Save and close the query.
Right-click your report in the navigation pane and select Design View.
Navigate to the Report Design tab on the ribbon and click on the Group & Sort option to open the sorting pane at the bottom of the screen.
Click 'Add a sort' in the pane, select the field you want to order by, and define your custom sorting criteria.

Create a Lookup Table for Custom Indexing
If you must enforce sorting within the query, create a separate table with numeric indexes to dictate the exact order of text values.
Looking for a Free and Lightweight Data Management Solution?
While Microsoft Access handles complex relational databases, WPS Spreadsheet offers an excellent, lightweight alternative for managing, sorting, and reporting large datasets. WPS Office is a free, highly compatible suite designed to handle your daily office tasks seamlessly.
- 1. Download the installer: Visit the WPS Office website and click the free download button.
- 2. Install the suite: Run the installer and follow the on-screen prompts to complete the setup.
- 3. Start sorting data: Open WPS Spreadsheet, import your data, and use the Data tab to apply custom sort orders instantly.

Frequently Asked Questions
Why do I get an ORDER BY and GROUP BY conflict in my crosstab query?
This error occurs because SQL rules dictate that any field used to sort (ORDER BY) the results of an aggregate query must also be explicitly included in the grouping logic (GROUP BY).
Can I sort an Access report without changing its underlying query?
Yes. You can completely remove the ORDER BY clause from the source query and instead use the Group & Sort feature in the Report Design view to arrange your data exactly how you need it.
What is the advantage of using a lookup table for sorting?
A lookup table allows you to assign a specific numeric priority to text categories. This provides complete control over the sorting order, enabling you to sort by logical sequences (like priority or workflow stages) rather than relying on default alphabetical sorting.




