Part Number Revision
001-001 A
001-001 B
001-001 C
001-001 D
001-001 E ..... goes up to Z then starts over with AB
001-001 AB
001-001 AC
If I write MAX(Revision), then I will get 001-001 Z since Access assume that
Z is the latest one since it is the last letter in the alphabet. But AC is
the max (the latest). I think Access sort it by A, AB, AC, B, C.... and so
on.
I want to know how would I write the code/set parameters so that AC is the
latest revision and not Z. OR is that not possible?
Only with a little help. Since your revision numbers are neither in numeric
nor alphabetic order, but rather use this idiosyncratic composite value (what
happened to AA for example!?), you'll need either a function or (perhaps
better) an auxiliary table.
If you had a table with all the possible values from A through ZZ (or more,
if you need to go on to DKZW...) along with a number field indicating that
value's sort order, you could Join your Revision field to this table by the
text value to retrieve the numeric sequence.
Or you could use a VBA function to return a sequence number; something like
the following
Public Function SeqNo(strRev As String) As Integer
strRev = UCase(strRev) ' make sure it's upper case
Select Case Len(strRev)
Case 0
SeqNo = 0
Case 1
SeqNo = Asc(strRev) - 64 ' Asc("A") is 65
Case 2
SeqNo = 26 * (Asc(Left(strRev, 1)) - 64) + Asc(Mid(strRev, 2, 1)) - 64
Case Else
MsgBox "Erroneous input", vbOKOnly
SeqNo = 0
End Select
End Function
Examples:
?seqno("a")
1
?seqno("z")
26
?seqno("aa")
27
?seqno("az")
52
?seqno("ba")
53
?seqno("zz")
702
Note that this will call a VBA function for every record in your query, and
not take advantage of any indexing.