Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085

    Sorting in a Report


    I have a Database for a bowling league. I have a report that shows the standings based on a query that is sorted by Percentage calculated by adding (wins + ties)/(wins + losses + ties) To give a percentage of wins. It works except 2nd and 3rd place are switched 2nd place has a win percentage of .56 and 3rd has .53 but the query and report shows the team with .53 in 2nd place and .56 in 3rd. I don't understand why it does that. Nothing I do changes it. Any thoughts?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Reports take NO NOTICE of the data order in it's source.
    You use the Sort option in the report.
    Last edited by Welshgasman; 11-15-2024 at 03:46 AM.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    Quote Originally Posted by Welshgasman View Post
    Reports take NO NOTICE of the data oder in it's source.
    You use the Sort option in the report.
    I sort it in the query. I also use the sort in the report it doesn't change anything

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Ray,
    Sorting in the query is ignored when reporting via Report. When using Report, as welshgasman said, you must use the sorting option within the Report---see Group, Sort, Total in Report options.

    If this doesn't help, then you might want to post a copy of the database for others to "attempt solution".

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    You need to sort descending, that will make highest values first.
    Last edited by davegri; 11-14-2024 at 05:42 PM. Reason: clarif

  6. #6
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    As I stated earlier I sort in the query and in the report. doesn't change. davegri I do sort descending every other record 1st and 4th through 7th are sorted correctly it's 2nd and 3rd that are switched

  7. #7
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    tried to attach the file but it's too big by .10 MB tried compact and repair and zipping it but 2.10 is the smallest I can get it and the error message says 2.0 is as big as I can upload.

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Can you post an image of the report (or a pdf of the report)?
    It could be that you are sorting on fields in addition to the average, and those sorts have higher priority than the averages.

  9. #9
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    If the copy your file is too big after being zipped and it has embedded images or attachment fields, removing those will be a big help. You could also delete tables/queries/forms/reports not needed to replicate the issue. Just make sure that what you end up with produces the same problem.

    EDIT - I was also wondering if your field data type is String, but I can't see that being the issue for the values you posted (.56 and .53). Doesn't seem as though it could be due to rounding either.
    Last edited by Micron; 11-14-2024 at 07:36 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by RayMilhon View Post
    tried to attach the file but it's too big by .10 MB tried compact and repair and zipping it but 2.10 is the smallest I can get it and the error message says 2.0 is as big as I can upload.
    Create a new DB and import ONLY what is needed to see the issue.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    Are you sorting on any other field?

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Just to reiterate what others have said, the report creates it's own version of the query data and applies sorting and grouping to it internally based on the settings in the report.
    There is zero point in applying any sort order to the reports recordsource, as it is never used, and will simply slow down the operation of the query on larger datasets.

    I suspect you have something (a grouping or section sort order) in the report that is overriding your desired results.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    Quote Originally Posted by davegri View Post
    Can you post an image of the report (or a pdf of the report)?
    It could be that you are sorting on fields in addition to the average, and those sorts have higher priority than the averages.
    Here's a screenshot of the report design and the report preview.
    Here is the query. All fields in tbl)standings are numeric the only field that is not numeric in this report is the Teams.team field which is the team name.


    Code:
    SELECT Teams.Team, tbl_standings.Wins, tbl_standings.losses, tbl_standings.Ties, ([wins]+([ties]*0.5))/([wins]+[Losses]+[Ties]) AS PCT, tbl_standings.[Total Pins]
    FROM tbl_standings INNER JOIN Teams ON tbl_standings.TeamID = Teams.ID
    ORDER BY ([wins]+([ties]*0.5))/([wins]+[Losses]+[Ties]) DESC;
    Attached Thumbnails Attached Thumbnails Screenshot 2024-11-15 081719.jpg   Screenshot printpreviewstandings.png  

  14. #14
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Can you try to wrap the PCT calculated field in a CDbl() or CSng() function and see what you get?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  15. #15
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Maybe you can't reliably sort on a calculation. However, you already have assigned that expression/calculation to PCT so why are you not just sorting on PCT?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 01-12-2012, 07:55 PM
  2. report formating/sorting problem
    By bill4364 in forum Reports
    Replies: 1
    Last Post: 02-19-2010, 08:15 PM
  3. sorting a field in report
    By Philangr8 in forum Reports
    Replies: 3
    Last Post: 08-26-2009, 05:38 PM
  4. Access report with 3 tables -grouping,sorting
    By kartechy in forum Reports
    Replies: 0
    Last Post: 07-22-2009, 09:07 AM
  5. Sorting data in a report
    By rjsiler in forum Reports
    Replies: 1
    Last Post: 08-04-2008, 01:40 AM

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