Include date sorting in a VBA filter button (1 Viewer)

templeowls

Registered User.
Local time
Today, 11:04
Joined
Jun 11, 2019
Messages
120
Hi so my form has a button that when pressed, it filters down to certain entries. However when it filters, it no longer sorts the entries from oldest to newest by date. It's just randomly mixed up. Is there anyway to include something in the code that will sort from oldest to newest by date?

The VBA code that I am using for the button is:

Code:
Private Sub btnNotStarted_Click()
    DoCmd.ApplyFilter , "[Status]= 'Not Started'"
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:04
Joined
May 7, 2009
Messages
14,021
Can you add to the code:

DoCmd.SetOrderBy "[Entry Date Fieldname] DESC"
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:04
Joined
Feb 19, 2002
Messages
33,168
Is the date sort in your RecordSource query?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:04
Joined
Feb 19, 2002
Messages
33,168
Which worked? It helps people who find this thread later to know what actually worked for you.
 

Users who are viewing this thread

Top Bottom