Sorting in access queries

reggied

New member
Local time
, 19:23
Joined
May 27, 2025
Messages
14
I have a query that only has 4 fields: SalesOrder, SalesOrderID, FabSO, and PODate. When it is sorted by PODate it sorts as shown below:


SalesOrderSalesOrderIDFabSOPODate
SDR049
qryUniqueSOFromtblTempFabReq
[td]
3443
FAB022
SDR050FAB022
SDR051FAB022
[td]
5/13/2025
[/td]​
[td]
3444
[/td]​
[td]
5/13/2025
[/td]​
[td]
3447
[/td]​
[td]
5/15/2025
[/td]​
[/td]


If I create a 2nd query that only pulls in the SalesOrder and PODate fields and sort by PODate I get the below result:


SalesOrderPODate
SDR050
Query1
[td]
5/13/2025
SDR049
[td]
5/13/2025
SDR051
[td]
5/15/2025
[/td]​
[/td]
[/td]

Any guesses as to why it switched the order?
Only asking because I am using Allen Browne's ConcatRelated function and it is sorting the list as shown in Query1 even though it is sorted by PODate. I thought there might be a time component that's causing a secondary sort but:


SalesOrderPODateTime
SDR050
Query1
[td]
5/13/2025
SDR049
SDR051
[td]
12:00:00 AM
[/td]​
[td]
5/13/2025
[/td]​
[td]
12:00:00 AM
[/td]​
[td]
5/15/2025
[/td]​
[td]
12:00:00 AM
[/td]​
[/td]
 
Trying to figure out how t delete this post because the tables are not viewing correctly. Also, I solved the issue by adding a secondary sort after the PODate sort.
 
When you have ties there's no predicting how its going to sort.

If you want to ensure the same sorting you should add a unique field in addition to the date one.
 
To have tables post correctly see discussion. This used to work.

You can always edit or delete a prior post. See buttons at the bottom of the post.
 
When you have ties there's no predicting how its going to sort.
Usually when the BE is Jet/ACE you won't see any difference due to the way that the database engines return rows. Since SQL Server, et al are multi thread, several tasks can be fetching at the same time and the result is unpredictable. So, you found the correct solution, add a tie-breaker but preferably use one that is unique if one is available.
 

Users who are viewing this thread

Back
Top Bottom