Thanks for your reply. Let me illuminate.
I am trying to sort serial numbers. Serial numbers can be any number of
characters, but usually fewer than ten. The only identifiable rules of serial
number construction are that alpha characters, if present, always start the
strings. There may be 0 to 6 alpha characters. Numeric data can start in the
first to seventh position.
The crucial idea is for the code to first sort the alpha characters in
ascending order (M before N, M before MA) and then numbers in ascending order
(N2 before N12)
I would prefer the sort to work in a query. If not possible to do in SQL, I
could use VBA in a module.
:
Can someone help me out with the string sorting?
I have a query that sorts data alphabetically like this:
N1456
N2
P12345
P1500
I would like to see the data ordered like this:
N2
N1456
P1500
P12345
Thanks
Not enough information.
Sort the data in the query?
Does the numeric value always start at the second character spot?
Add 2 new columns in this order:
SortLetter:Left([FieldName],1)
SortNumber:Val(Mid(FieldName],2))
Sort according to these new columns. Make sure the SortLetter column
is to the left of the SortNumber column.
Sort the data in a Report?
In Report Design View, click on View + Sorting and Grouping.
Enter SortLetter and SortNumber (in that order) in the
Field/Expression column.