Results 1 to 10 of 10
  1. #1
    norseman's Avatar
    norseman is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    Oregon
    Posts
    22

    Not Sorting Numbers Correctly in a Report

    I have a database that stores data about different kits that I build. The data structure is

    Field Name Data Type Explanation of what is stored in the field
    ID AutoNumber Key
    Kit Short Text Kit Name
    PartNo Short Text Manufacturer Part Number
    Man_Id Number Manufacturer ID Number
    Book_lid Number Book ID where Instructions and key information are kept
    Pg Number Page number where Instructions are
    Qty Number Quantity of the kit
    Dr Number What Drawer Kit is stored
    Sl Number What Slot in Drawer where kit it stored
    Finish Short Text What type of finish has been applied to kit
    UpperDrill Short Text Drill bit size for main
    LowerDrill Short Text Drill bit size if there are two drills needed
    Bushings Short Text ID of the bushings I will use to work on the kit
    Tubes Short Text Size of tubes (if needed) for kit


    I am building a report where I want to sort all the kits by the Drawer and Slot where they are stored
    The report is built with a sort (ascending) on drawer and then a sort (ascending) on Slot.

    When I view the report, the drawer sort comes out as
    Drawer Slot
    1 1
    1 2
    1 3
    1 4
    1 5
    10 1
    10 2
    10 3
    10 4
    10 5
    11 1
    11 2
    11 3
    11 4
    11 5
    2 1
    2 2
    2 3
    2 4
    2 5

    I want it to sort the drawer number correctly: 1,2,3,4,5,6,7,8,9,10,11, etc.. then sort the slot the same way
    I know this is not a major type problem, but it is an annoyance when I need the report

    I have tried both storing the drawer number as text or as a number



    I have looked around in this forum as well as the internet in general, but I have not found a way to fix this problem.

    What am I not doing that I should be doing
    Last edited by norseman; 11-05-2023 at 11:39 AM.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    You say
    Dr Number What Drawer Kit is stored
    yet for some reason, Drawer is text. That's why 10 comes before 2.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Are you positive those fields are defined as number type in table?

    Is report RecordSource a query? Post the SQL statement.

    Could provide db for analysis. Follow instructions at bottom of mypost.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    norseman's Avatar
    norseman is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    Oregon
    Posts
    22
    Quote Originally Posted by Micron View Post
    You say
    Dr Number What Drawer Kit is stored
    yet for some reason, Drawer is text. That's why 10 comes before 2.
    I do not understand why you say the Drawer is text? Maybe this will clear things up. In the table the first column is the name of the field the second column is what the field is stored as, and the third is an explanation of what the field is. I will edit my post to make this more clear.

    In the current db Drawer is stored as a number. I have tried restructuring the db so that Drawer is stored as text but it still did not print the way I want.

    The Dr stands for the Drawer where the kit is stored. They are numbered 1 thru 13. Each Drawer has up to 11 slots where the actual kit is stored. Given kit xyz can be found in drawer 3, slot 9

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You should not be doing the sorting (by the numeric Drawer and Slot) in the report's recordsource, but in the report's Design view by going to Grouping and Sorting.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    norseman's Avatar
    norseman is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    Oregon
    Posts
    22
    I figured it out, my mistake. It was your question about the RecordSource that got me checking it with a fine tooth comb. The RecordSource query was attached to the wrong db.

    When I started fooling around with this problem I made a copy of the db and the report (thus the query with it). I thought I had changed the db in the query to the copy but it was still attached to the original db where Dr was defined as short text. When I changed the everything to the correct db, with the correct query RecordSource for the report to make Dr and Sl numbers, and used the correct query (where I told it to sort Dr (ascending), and attached to the correct copy of the report, everything came out as I wanted it to.

    Thank you for your reply, it got me started looking in the correct place

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Recordsouce sort sequence is ignored by report, as mentioned by Vlad.
    You need to do the sort in the report.
    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

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I do not understand why you say the Drawer is text?
    because that is how numbers that are text data type are sorted. It was a dead giveaway. If it turned out that the source data type was in fact integer or some other number type then it would have to be that your query makes use of a conversion function that converts number types to text. I can think of no other possibility for why 10 would sort ascending before 2.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by Micron View Post
    because that is how numbers that are text data type are sorted. It was a dead giveaway. If it turned out that the source data type was in fact integer or some other number type then it would have to be that your query makes use of a conversion function that converts number types to text. I can think of no other possibility for why 10 would sort ascending before 2.
    If you make you feel any better, lots of so called 'profressional' software does exactly the same thing.

    I use Xero and that does that.
    I used to use the SSAFA CMS system and that did that as well. :-(
    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

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    A field defined as text type permits digits, letters, punctuation, symbols (all are just characters in a text field) therefore alpha sort rules must apply. This means ordering is determined one character at a time.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Sorting Numbers (Reopened)
    By zburns in forum Access
    Replies: 5
    Last Post: 08-04-2015, 03:32 PM
  2. Won't Import my Numbers Correctly
    By tanyalee123 in forum Import/Export Data
    Replies: 2
    Last Post: 12-18-2014, 01:48 PM
  3. Query not sorting correctly?
    By Areteauu in forum Queries
    Replies: 2
    Last Post: 01-27-2014, 02:37 PM
  4. Sorting numbers on a report
    By paul123 in forum Access
    Replies: 6
    Last Post: 02-15-2012, 03:34 PM
  5. Date not Sorting Correctly (screenshot attached)
    By KrenzyRyan in forum Queries
    Replies: 5
    Last Post: 06-27-2011, 01:44 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