Results 1 to 3 of 3
  1. #1
    PDilly is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    78

    Mainform filter disrupts subform sort

    I have a main form with a subform. The main form loads with records ascending by ID as they are stored in the table which is correct.
    The subform has an Order on Load property which sorts by year descending ( the latest is always displayed first).

    When the forms open the sort is perfect and whether cycling through records or picking specific ones, the year sort remains correct.

    The main form has a number of filters Which when used, filter records on the main foerm but remove the subform year sort. On the face of it, they come in table order which is generally ascending.

    Having used a filter, the sort doesn't kick back in until the form is closed and loaded again.



    The code for the filters is generally the same and pasted below. I think, but i'm not certain, that I need another OrderBy statement, perhaps somewhere in the filter code.

    Can anyone confirm please?

    Private Sub Command270_Click()
    If Me.Form.FilterOn = True Then
    Me.Form.Filter = ""
    Me.Form.FilterOn = False
    Me!Command270.Caption = "Apply LAPSED Filter"
    Me.Command270.BackColor = RGB(0, 255, 0)
    [FltrStatus] = Null
    [Combo290].Requery
    Else:
    Me.Form.Filter = "[STATUS] = 'LAPSED'"
    Me.Form.FilterOn = True
    Me!Command270.Caption = "Remove LAPSED Filter"
    Me.Command270.BackColor = RGB(255, 0, 0)
    [FltrStatus] = "LAPSED"
    [Combo290].Requery
    End If
    Myfilter = Me.Form.Filter
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Sounds reasonable. I tested and seems to do the trick. Give it a try.

    Me.subformcontainername.Form.OrderByOn = True
    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
    PDilly is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    78
    Quote Originally Posted by June7 View Post
    Sounds reasonable. I tested and seems to do the trick. Give it a try.

    Me.subformcontainername.Form.OrderByOn = True

    Yes, that works. Many thanks

    funny that it took 6 months for the user to find it wasn’t working 🤣🤣

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

Similar Threads

  1. Replies: 6
    Last Post: 04-13-2018, 04:19 PM
  2. Replies: 1
    Last Post: 03-22-2015, 02:21 PM
  3. Replies: 1
    Last Post: 11-07-2012, 05:31 PM
  4. Replies: 4
    Last Post: 03-30-2012, 01:47 AM
  5. Filter a subform based on mainform
    By Cheshire101 in forum Queries
    Replies: 3
    Last Post: 01-06-2011, 12:56 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