Gasman
Enthusiastic Amateur
- Local time
- Today, 14:03
- Joined
- Sep 21, 2011
- Messages
- 16,440
We often get queries here as to how one can sort data like addresses where 110 Magnolia Drive comes before 2 Magnolia Drive, as the data is text.
Just found this code here, that at least allows for a way around that and very easily to.
Thank you Philip @sonic8
https://codekabinett.com/rdumps.php?Lang=2&targetDoc=logical-numerals-sorting-access-vba
I know the author frequents here, but I cannot remember his username. Edit: @AccessBlaster reminded me of the name.
The only problem is that it is for 64 bit Access as posted on that site, and I only use 32bit Access 2007.
I have amended it for my system by the code below. That is all that is needed and have tested it on my system.
Just found this code here, that at least allows for a way around that and very easily to.

https://codekabinett.com/rdumps.php?Lang=2&targetDoc=logical-numerals-sorting-access-vba
I know the author frequents here, but I cannot remember his username. Edit: @AccessBlaster reminded me of the name.
The only problem is that it is for 64 bit Access as posted on that site, and I only use 32bit Access 2007.
I have amended it for my system by the code below. That is all that is needed and have tested it on my system.
Code:
#If VBA7 Then
Private Declare PtrSafe Function LCMapStringEx Lib "Kernel32.dll" (ByVal lpLocaleName As LongPtr, ByVal dwMapFlags As Long, ByVal lpSrcStr As LongPtr, ByVal cchSrc As Long, _
ByVal lpDestStr As LongPtr, ByVal cchDest As Long, ByVal lpVersionInformation As Long, _
ByVal lpReserved As Long, ByVal sortHandle As Long) As Long
#Else
Private Declare Function LCMapStringEx Lib "Kernel32.dll" (ByVal lpLocaleName As Long, ByVal dwMapFlags As Long, ByVal lpSrcStr As Long, ByVal cchSrc As Long, _
ByVal lpDestStr As Long, ByVal cchDest As Long, ByVal lpVersionInformation As Long, _
ByVal lpReserved As Long, ByVal sortHandle As Long) As Long
#End If
Last edited: