Increment Alphabetical Character

D

Dave

I am in the process of creating a database for logging and creating
Drawing Numbers for my company. What I am having a question on is
incrementing an Alphabetical character.

The conext got this is that the Fabrication Drawing series are number
like FD12- then the drawing item number. In this case, the FD12 is a
reference to a particular job. I can increment the numberical component
easily enough, but once I get to FD99-, then number in the series would
be FE00-. How can I make this increment??
 
D

Dave

Ok, so after spending the better part of yesterday and this morning
working on this project, here is how I got this to work:

strLastNo = Nz(DMax("[Drawing Number]", "newfabdwg", _
"[Drawing Number] Like 'F*'"), "No")

If strLasNo = "No" Then
strDrawingNo = "FA01"
ElseIf Right(strLastNo, 2) = "99" Then
strDrawingNo = Left(strLastNo, 2)
strDrawingNo = Right(strDrawingNo, 1)
strDrawingNo = Asc(UCase(strDrawingNo))
strDrawingNo = strDrawingNo + 1
strDrawingNo = Chr(strDrawingNo)
strDrawingNo = "F" & strDrawingNo & "01" & NewFItem

Else
strDrawingNo = strDrawingNo &
Format(CInt(Right(strLastNo, 2) + 1), "00") & NewFItem
End If

I use the DMax function to get the latest F number out of a table.
If there is no number, then it creates FA01
It the last 2 characters are 99 (EG FA99, FB99, FC99, etc), then the
program take the first 2 characters (FA) and stores them as a variable,
then takes the last character (A) and redefines the variable. Then
convert that letter to ascii, increase the ascii by 1, and convert back
into a number.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top