sort the records in a form using 2 criteria

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
marian68Asked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
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
 
kavik379Commented:
Create a query to use as the record source of the form that uses the two criteria you want to Order By.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
marian68Author Commented:
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
 
marian68Author Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"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
 
marian68Author Commented:
Thanks a lot.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
you are welcome ...

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.