access 2007 vba using chr()

I am working on a function to automatically create a lot number.

This is the format:  GAA0001

It first gets the last lot number used from the table.
Then look at the numeric section to see if it is at 9999.
If so, it needs to look increment the 3rd letter.  If the 3rd letter is Z, it should set it to A and increment the 2nd letter.

I know that chr(65)  is "A" and chr(90) is Z

Is there a way to work on the 3rd letter like this?
strCharacters = "GAA1234"
strLetter = mid(strCharacters, 3)
if strLetter is greater than chr(90) then
      strLetter = chr(65)

Then I'll go on to look at and increment the 2nd letter if needed.

I know I have data type mismatches in there... that is what I'm trying work around.

Who is Participating?
Lee W, MVPConnect With a Mentor Technology and Business Process AdvisorCommented:
ASC should take the ASCII value of the character and check itYou can also change the case in advance so you don't need to do that.strCharacters = "GAA1234"strLetter = mid(UCase(strCharacters), 3)if strLetter is greater than chr(90) then      strLetter = chr(65)endifThe added UCASE should change the case to upper case so you ALWAYS get a character between 65 and 90.
Lee W, MVPTechnology and Business Process AdvisorCommented:
Use ASC - If Asc(StrLetter) > 90 Then StrLetter = 65
All Courses

From novice to tech pro — start learning today.