Custom Sort for sorting records like aaabbbccc to abcabcabc

Local time
Today, 07:31
Joined
Mar 23, 2022
Messages
45
Hi everyone,

I am new to Access Programming.

I am having data as

a
a
a
b
b
b
c
c
c

Now I want to sort the sort the record as

a
b
c
a
b
c
a
b
c

Anyone kindly hep me.

Thanks

Amir Kharkongor
 
you need a Temp table to do that. plus additional Autonumber field to original table.
plus a VBA. so it is not simple.
 
what is you actual data? only a, b, c?
 
what is you actual data? only a, b, c?
something like

USA, 100
USA, 100
USA, 100
Australia, 100
Australia, 100
Australia, 100
China, 100
China, 100
China, 100

I want it sorted liked

Australia, 100
China, 100
USA, 100
Australia, 100
China, 100
USA, 100
Australia, 100
China, 100
USA, 100
 
Consider:

SELECT Table1.*
FROM Table1
ORDER BY DCount("*","Table1","Country='" & [Country] & "' AND ID<=" & [ID]), Table1.Country;

Be aware, domain aggregate function can cause slow performance with large dataset.
 
Last edited:

Attachments

  • Screenshot 2022-03-23 094537.png
    Screenshot 2022-03-23 094537.png
    11.4 KB · Views: 284
  • Test.zip
    Test.zip
    18.8 KB · Views: 267
here's another flavour:

SELECT Table1.*
FROM Table1 ORDER BY
Dcount("1","Table1","Country='" & [Country] & "' And ID <= " & [ID]) & [Country]
 
here's another flavour:

SELECT Table1.*
FROM Table1 ORDER BY
Dcount("1","Table1","Country='" & [Country] & "' And ID <= " & [ID]) & [Country]
It works and finally I could proceed with my project.

Thank You very much.
 
@Pat Hartman, already demonstrated how this can be done without a grouping field in table. The grouping field is calculated. However, a unique identifier field is needed. Autonumber type serves and is easily added to table if not already there.
 

Users who are viewing this thread

Back
Top Bottom