Solved

sort the records in a form using 2 criteria

Posted on 2011-03-09
9
372 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 75

Accepted Solution

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

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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.

679 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