Results 1 to 5 of 5
  1. #1
    bilalo is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    107

    Report custom sort

    I have a table Category with P.K categories.
    One of the categories is "Discount", I want a query that displays it at the end of the list.
    I run the following query, and it works perfectly: SELECT categories FROM Category ORDER BY IIf(categories<>'Discount',1,2), categories
    The problem is when I generate a report that is grouped on categories, I only have 2 choices: with A on top and with Z on top, and there is no place to put a custom sort.


    I tried to sort the report query but didn't work.
    I also changed the order by property of the report and still didn't work.
    I think the sorting that is applied to the group (with A on top) is overriding all my sorts attempts

    Any idea on how to apply a custom sort on a report?

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Reports have their own sorting and grouping functionality.
    You could add a field to your table - MySortFld - with values that have meaning to your custom sort.

  3. #3
    bilalo is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    107
    Quote Originally Posted by orange View Post
    Reports have their own sorting and grouping functionality.
    You could add a field to your table - MySortFld - with values that have meaning to your custom sort.
    So there is no other choice than modifying the table?
    I was thinking to add a special character at the beginning of the word "Discount", so that it appears at the end of the list. Any idea about a character that comes after 'Z' in MS Access. I tried many special characters such as .Discount,@Discount,(Discount) but all of them makes it at the top of the list.

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    So there is no other choice than modifying the table?
    no, just modify the query to include a sort value - then sort in the report

    SELECT categories, IIf(categories<>'Discount',1,2) AS sortValue FROM Category

    then in your report sort the sortValue column

    there is zero benefit in sorting the query when used in the report, just takes longer since it effectively gets sorted twice

  5. #5
    bilalo is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    107
    Quote Originally Posted by Ajax View Post
    no, just modify the query to include a sort value - then sort in the report

    SELECT categories, IIf(categories<>'Discount',1,2) AS sortValue FROM Category

    then in your report sort the sortValue column

    there is zero benefit in sorting the query when used in the report, just takes longer since it effectively gets sorted twice
    Yes works perfectly. Thanks for the help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query with custom sort
    By bilalo in forum Queries
    Replies: 6
    Last Post: 06-24-2019, 01:24 PM
  2. Combo Box - Custom Sort Order
    By twildt in forum Access
    Replies: 4
    Last Post: 05-22-2014, 01:38 PM
  3. Replies: 1
    Last Post: 02-27-2012, 06:22 PM
  4. Problem with EOF in custom report
    By ino_mart in forum Programming
    Replies: 4
    Last Post: 09-27-2011, 02:56 PM
  5. Custom Report Printing
    By robocopfl in forum Reports
    Replies: 3
    Last Post: 06-04-2010, 12:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums