Question : 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)
endif

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.

Thanks,
Brooks

Answer : access 2007 vba using chr()

ASC should take the ASCII value of the character and check it

You 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)
endif

The added UCASE should change the case to upper case so you ALWAYS get a character between 65 and 90.
Random Solutions  
 
programming4us programming4us