sample 3 includes sample2.
we need to use a user function to solve this. put following user function in a modoule:
Code:
Public Function formatStr(sstr As String) As String
Dim i As Long
i = Len(sstr)
Do While Mid(sstr, i, 1) <= "9"
i = i - 1
If i = 0 Then Exit Do
Loop
formatStr = Format(Mid(sstr, i + 1), "0000000000")
If i = 0 Then
formatStr = Format(sstr, "0000000000")
Else
formatStr = Left(sstr, i) & Format(Mid(sstr, i + 1), "0000000000")
End If
End Function
then in your query:
select ... order by formatStr(ServiceID)