Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

sort the records in a form using 2 criteria

Posted on 2011-03-09
Last Modified: 2012-05-11
How could I see the records in a form using 2 criteria, the date(chronologic order) in a field and ordre alphabetic in another field.
Thank you
Question by:marian68
  • 5
  • 3

Expert Comment

ID: 35087259
Create a query to use as the record source of the form that uses the two criteria you want to Order By.
LVL 75
ID: 35087285
Maybe using a query as the Record Source for the form ... example:

SELECT Table1.*
FROM Table1
ORDER BY Format([End Date],"yyyymmdd"), Table1.FIELD1;


Author Comment

ID: 35087423
The form is rather complex. I can not afford to build the form again based on the query you are proposing.
Other ideas?
Thank you
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

LVL 75

Accepted Solution

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 35087527
You can try this code if the Form Load event:

Private Sub Form_Load()
    Me.OrderBy = "[YourDateFieldName], [YourOtherFieldName]"
    Me.OrderByOn = True
End Sub

"I can not afford to build the form again based on the query you are proposing."
But that is *very* easy to do ... requires virtually no change.



Author Closing Comment

ID: 35087769
Thank you. It works.
"But that is *very* easy to do ... requires virtually no change."
Could you tell me how to do that or give me some hints?
Thank you
LVL 75
ID: 35087880
"Could you tell me how to do that or give me some hints?"
Sure ...
Your Form is currently based on a table, right ?

See the steps below ... just create the SQL off of the existing table and make that the RecordSource - or same it as a Named query ... and use that query.


Author Comment

ID: 35087995
Thanks a lot.
LVL 75
ID: 35088027
you are welcome ...

LVL 75
ID: 35088039
Best to save the newly created query (SQL) as a saved query in the db window, then use that as the RecordSource.  But either way requires no change to the Form really.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Insert Into syntax error 10 29
Microsoft Access Dcount --   check if  field has a valid date 5 33
Record with #Error 8 33
trim dropdown value before executing query 8 26
As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question