Results 1 to 6 of 6
  1. #1
    SteveApa is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    84

    ado_rs.sort does not compile

    Hi.



    Access front end / sql server backend. I have vba sql to pull data from 3 joined tables. T1 left join to T2 Left joined to T3. I do not know if the T3 has any entries so I cannot add an "Order by T3.Element desc". I have to wait until I get the results to find out if there are any T3 elements. If I add the order by to the sql and there are no elements, I get a error as expected. So, I thought I would run and then use the ado_rs.sort I searched the web and found you .... ado_rs.Sort "ElementNameToBeSorted desc, ElementNameOfOtherToBeSorted asc". But, I get a compiler error: Invalid use of property. I got syntax from
    HTML Code:
    https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/sort-property-example-vb?view=sql-server-ver15
    I assume there is not a special reference I need... all other ado stuff works as expected.

    Can anyone help?

    Steve
    Harrisburg, PA

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This worked for me, note the = sign:

    ado_rs.Sort = "ElementNameToBeSorted desc, ElementNameOfOtherToBeSorted asc"
    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.

  3. #3
    SteveApa is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2015
    Posts
    84
    Quote Originally Posted by June7 View Post
    This worked for me, note the = sign:

    ado_rs.Sort = "ElementNameToBeSorted desc, ElementNameOfOtherToBeSorted asc"
    I tried that and I get error message
    "Run-time error '3251':
    Current provider does not support the necessary interfaces for sorting or filtering."

    I am windows 10 64bit, Microsoft® Access® for Microsoft 365 MSO (16.0.14326.20702) 32-bit

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Sorry, can't help with Office365.

    My actual VBA is: rst.Sort = "FAAID DESC"
    I assumed you have actual field names in place of ElementNameToBeSorted and ElementNameOfOtherToBeSorted.
    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.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Haven't used it myself, but I see this in the documentation: "This property requires the CursorLocation property to be set to adUseClient." Is that the case?
    Last edited by pbaldy; 04-20-2022 at 04:11 PM. Reason: Fix spelling goof
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Good point. Yes, it does make a difference.

    Perhaps OP should give us their actual code.
    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. compile error
    By docweaver in forum Modules
    Replies: 8
    Last Post: 07-14-2017, 05:34 PM
  2. Help with Compile error
    By Gregm66 in forum Access
    Replies: 9
    Last Post: 09-20-2016, 10:22 PM
  3. Replies: 1
    Last Post: 04-07-2014, 02:59 AM
  4. sort filter, doesn't sort everything
    By deso in forum Queries
    Replies: 4
    Last Post: 01-25-2013, 05:27 AM
  5. How to sort by three sort orders
    By captgnvr in forum Access
    Replies: 4
    Last Post: 11-09-2009, 07:30 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