M
Mike
The original thread seems to have diappeared from the newsgroup so I'm starting again.
We have a box id number say 1234 then we add a alpha for each element
in the box 1234A, 1234B, 1234C and so on. How can we have the alpha
part be added automaticaly.
I received this answer from Graham Mandeno which works great, but what happens when you get to the letter Z, we usally start going with AA, AB, AC etc.
Chr(Asc(Nz(DMax("ElementLetter","tblElements", _
"BoxNum=" & Me.BoxNum), "@")) +1 )
To break this down, working from the inner brackets outwards:
DMax(...) finds the highest letter used so far for the given BoxNum
Nz(..., "@") says to use an "@" sign (the ASCII character before "A") if there is no record for that BoxNum
Asc(...) + 1 takes the ASCII code value for the letter we have found and adds 1
Chr(...) converts the result back to a letter - the next one in the sequence.
We have a box id number say 1234 then we add a alpha for each element
in the box 1234A, 1234B, 1234C and so on. How can we have the alpha
part be added automaticaly.
I received this answer from Graham Mandeno which works great, but what happens when you get to the letter Z, we usally start going with AA, AB, AC etc.
Chr(Asc(Nz(DMax("ElementLetter","tblElements", _
"BoxNum=" & Me.BoxNum), "@")) +1 )
To break this down, working from the inner brackets outwards:
DMax(...) finds the highest letter used so far for the given BoxNum
Nz(..., "@") says to use an "@" sign (the ASCII character before "A") if there is no record for that BoxNum
Asc(...) + 1 takes the ASCII code value for the letter we have found and adds 1
Chr(...) converts the result back to a letter - the next one in the sequence.