ACC: How to Sort String Values Based on their Numeric ValuesID: Q96112
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article shows you how to sort alphanumeric string values based on
their numeric values.
The following example creates a query to sort alphanumeric strings by
their numeric portion. There can be only one character digit after the
number (that is, a, b, c; not aa, bc, cde). This query will work for any
size numbers, with or without leading zeroes.
Table: Table1
-----------------------
Field Name: ProductCode
Data Type: Text
10a
1d
100b
24c
24a
1
89b
14
Query: Query1
------------------------------------------------
Field: ProductCode
Show: Yes
Field: PRE: Val([ProductCode])
Sort: Ascending
Show: No
Field: SUF:IIf(Val(Right$([ProductCode],1))=0, _
Right$([ProductCode],1),"")
Sort: Ascending
Show: No
1
1d
10a
14
24a
24c
89b
100b
Keywords : kbusage QryOthr
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 20, 1999