Results 1 to 5 of 5
  1. #1
    mindea is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    11

    SetOrderBy ASC works but not DESC

    I have an Access form based on a single-table query (with no sorting) displaying Continuous Forms. I can manually click in any column and sort Ascending or Descending using the selectors in the Sort & Filter tool bar, or by right-clicking and selecting from the menu Sort Smallest to Largest etc.

    I added a button above the Managers column with this code: DoCmd.SetOrderBy "Managers, ASC" It works great.

    However, if I change the code to sort DESCENDING --DoCmd.SetOrderBy "Managers, DESC" -- it still sorts Ascending

    I've tried it against other columns with the same outcome -- can't get any column to sort Descending.

    Am I missing something?



    [Windows 10, Access/Office 365]
    Last edited by mindea; 12-11-2020 at 01:27 PM. Reason: update access version

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    I don't think you need the comma before asc or desc.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    Access probably thinks that DESC is a field.? as the default is ASC anyway?

    https://docs.microsoft.com/en-us/off...cmd.setorderby
    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

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Could you please try to replace the code in your button click event with:
    Code:
    Me.OrderBy = "Managers Desc"
    Me.OrderByOn = True
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    mindea is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2015
    Posts
    11
    Gadzooks! I was including a comma where none was needed.
    Many thanks for the help.

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

Similar Threads

  1. Return Top 5 in DESC Order regardless of Tie
    By mrmmickle1 in forum Programming
    Replies: 3
    Last Post: 03-19-2019, 08:43 AM
  2. Order By DateField... ASC if this / DESC if that
    By MatthewGrace in forum Queries
    Replies: 7
    Last Post: 12-15-2015, 03:30 PM
  3. Replies: 1
    Last Post: 06-21-2015, 07:58 AM
  4. Sort DESC not working
    By accessnewbie352 in forum Macros
    Replies: 6
    Last Post: 01-15-2015, 02:27 PM
  5. ORDER BY error when using DESC in an IIf
    By Smitoris in forum Queries
    Replies: 2
    Last Post: 10-30-2011, 02:48 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