Reputation: 608
I have a Form that has a continous subformcontining a few fields, important to this question is an ID field which is unique text and a due date field. Right not the form loads all records and they are sorted by the ID field by the OrderBy
property of the subform, not the query.
In the parent form I have headers for each column and a toggle button to sort activate and deactivate sorting by due date. Right now the form loads sorted by ID and when the toggle button is clicked it sorts by date as I want it to. But when the toggle button is clicked again, deactivating it, the form retains its sort by date.
Here is the code I currently have behind the toggle button:
Private Sub tglSortDueDate_Click()
If Me.tglSortDueDate = True Then
Me.sbfrmFindRecords.Form.OrderBy = "DueDate, ID"
Me.OrderByOn = True
Else
Me.sbfrmFindRecords.Form.OrderBy = "ID"
Me.OrderByOn = True
End If
Me.sbfrmFindRecords.Requery
End Sub
Is this possible or should I instead change the record source to switch between 2 queries with different sorts based on my record source table?
Thanks in advance
Upvotes: 0
Views: 465
Reputation: 608
I ended up taking a different approach, rather than sort on the form side I instead made 2 queries with the 2 diffent sorts based on the source query. I then switch between the 2 queries when the button is toggled.
Upvotes: 0