Solved

sort the records in a form using 2 criteria

Posted on 2011-03-09
9
359 Views
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
0
Comment
Question by:marian68
  • 5
  • 3
9 Comments
 
LVL 1

Expert Comment

by:kavik379
ID: 35087259
Create a query to use as the record source of the form that uses the two criteria you want to Order By.
0
 
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;


mx
0
 

Author Comment

by:marian68
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
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) 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.

mx

0
 

Author Closing Comment

by:marian68
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
0
 
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.

mx
Capture1.gif
Capture2.gif
Capture3.gif
Capture4.gif
Capture5.gif
0
 

Author Comment

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

mx
0
 
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.

mx
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

773 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