I have this code that filters my records, it contains 3 columns, is it possible to have it sort by Largest to Smaller for column: [Amount]?
I used Me.OrderBy
but it doesn't do anything, still shows te record in normal order.
Me.Filter = ""
Me.FilterOn = False
Me.ItemsQuerySubform.Form.RecordSource = _
"SELECT * FROM ItemsQuery WHERE ItemCode LIKE 'B*'"
Me.FilterOn = True
CodePudding user response:
As you are setting the .RecordSource
of the subform using a SQL statement, this can be modified to include ORDER BY
:
Me.ItemsQuerySubform.Form.RecordSource = _
"SELECT * FROM ItemsQuery WHERE ItemCode LIKE 'B*' ORDER BY [Amount] DESC;"
Note that you need to use DESC
to get the largest value first, decreasing to the smallest.