Results 1 to 10 of 10
  1. #1
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202

    order by not working


    Good morning,
    I have a continuous form that has multiple columns. The end user needs the ability to sort asc and desc in each of the columns. This is not possible without code on a continuous form. I have built command buttons to allow this in each of the columns. Works great on load of the form. There is the ability to use parameter to filter needed items based on a control in the form. (works great) When the form opens, I have set the default of the form "Me.OrderBy =PageID asc". The command code for each of the sort buttons is set to (based on the field I want to sort)

    Private Sub cmdAsc2_Click()
    Me.OrderBy = "MCFieldName ASC"
    End Sub

    and works great until I try and clear the parameter in the control using

    Private Sub cmdClearFilter_Click()

    txtFilterName = Null
    Me.RecordSource = "qryMgtMCField_Page"
    'Me.OrderBy = "PageID ASC"
    End Sub

    When I attempt to then go back and use the sort command buttons, they do not work. The property sheet shows that the sort should be with the corresponding field, but the command does not finish the execution by sorting (Orderby). Thoughts?

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You might need to show us some more of the code but if you want to remove the filter is always better to not only removing the value from the textbox and resetting the recordsource, but also turning the filter off in VBA:
    Code:
    Me.txtFilterName = Null
    Me.Filter=""
    Me.FilterOn=False
    Can you show us all the code for the sort buttons, I assume that you use toggle buttons and change their caption depending if the sort they apply is ascending or descending.

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

  3. #3
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202
    ContinuousFormSort.zip

    Here is an example. I am not using toggle buttons, but cmd buttons

  4. #4
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Please check this updated file.

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

  5. #5
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202
    Gicu, thank you very much. Can you please explain why I need to refresh after clicking the asc and desc buttons. It works before the clearing of filter without the refresh. I understand the other adjustments in the code, but not that one. Trying to grow. Appreciate you input and my insight very much

  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
    If it works satisfactorily without Refresh, remove it.
    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.

  7. #7
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Or you can replace it with Me.OrderByOn=True to apply the new sort:
    https://learn.microsoft.com/en-us/of...form-or-report

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

  8. #8
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Here is something that might make it easier for you if you want to do this on multiple forms\columns:
    https://www.tek-tips.com/viewthread.cfm?qid=1750380
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    This is not possible without code on a continuous form
    not quite true, you can use the shortcut menu on the textboxes (unless you have disabled shortcut menus)

  10. #10
    mlrucci is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Apr 2018
    Posts
    202
    oooo nice. Thank you

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

Similar Threads

  1. Sort order of RecordSource not working
    By GraeagleBill in forum Reports
    Replies: 2
    Last Post: 10-13-2021, 05:36 PM
  2. Order by not working so well
    By SuperDude_123 in forum Queries
    Replies: 5
    Last Post: 04-11-2018, 12:35 PM
  3. Working with Different Order Services
    By francogaspari in forum Access
    Replies: 2
    Last Post: 06-18-2014, 09:22 AM
  4. order by dlookup not working
    By broof in forum Queries
    Replies: 3
    Last Post: 01-11-2011, 03:15 PM
  5. Forms Order By not working
    By cowboy in forum Forms
    Replies: 3
    Last Post: 04-21-2010, 10:29 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