Avatar of Derek Brown
Derek Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Ordering records on a continuous form

When using this expression:

Me.RecordSource = "Select * from Lock Order BY Lock Desc"

Is there any way to include a second column or field order at the same time. I.e.:

Me.RecordSource = "Select * from Lock Order BY Lock Desc" and then Me.RecordSource = "Select * from Lock Order BY Size Desc"
Microsoft Access

Avatar of undefined
Last Comment
Derek Brown

8/22/2022 - Mon
Jonathan Kelly

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Anders Ebro (Microsoft MVP)

It has to be a single expression so:
Me.RecordSource = "Select * from Lock Order BY Lock Desc, Size Desc" 

Open in new window

You can add as many expressions as you'd like.
John Tsioumpris

You can also keep the way of setting the RecordSource of your Form and then on Form Level (e.g. via a button) add additional sorting ..
I used it a lot in continuous forms with many fields to have a click event on the Labels of the fields to dynamically sort.
The Code is like this :
Me.OrderBy = "Size DESC"
Me.OrderByOn = True

Open in new window

Check the Ms Article on this : https://docs.microsoft.com/en-us/office/vba/access/concepts/forms-design/change-the-filter-or-sort-order-of-a-form-or-report
Jim Dettman (EE MVE)

and FYI, a good way to learn SQL is to open the query designer, build what you need, and switch to SQL view and see the resulting statement.

You can go the other way as well if you already have a SQL statement.   Switch to design view, paste in the SQL statement, switch to design view and modify as needed, then switch back.

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
Derek Brown

I can't believe I have never noticed that in sql before. I don't normally have much need of two levels of order.

So simple, for once.

Thanks all!