Microsoft Access - Is it possible to add a numeric and an alphanumeric fields together?

Asked By Cortney on 14-Jun-12 11:13 AM
I am trying to add a pay grade field (ex. E46, E50, E56, N46) to a number field (the number of grades it will increase next year 1, 2, 3). Is it possible to add E46 + 1 to display E47?
Neha Garg replied to Cortney on 14-Jun-12 01:43 PM
Hello Cortney,

for that you need to use the alpha numeric field and the increment or calculate the numeric value of the field...

to achieve this see the code on the below link:


http://www.devhut.net/2010/10/30/ms-access-auto-increment-a-value/

http://www.techonthenet.com/access/functions/misc/alphanumeric.php




wally eye replied to Cortney on 14-Jun-12 06:59 PM

You could create a function like this:

Public Function BumpGrade(ByVal strGrade As String, ByVal intBump As Integer) As String

    Dim intPos      As Integer
    Dim intGrade      As Integer

    For intPos = 1 To Len(strGrade) - 1
      If IsNumeric(Mid(strGrade, intPos, 1)) Then
        BumpGrade = Left(strGrade, intPos - 1) & CStr(Val(Mid(strGrade, intPos)) + intBump)
        Exit For
      End If
    Next intPos

End Function

Jitendra Faye replied to Cortney on 15-Jun-12 12:55 AM
For this first you need to extract numeric part from the given value.

try to get  numeric value than you can add particular number to that resulted nuber , after calculation again you need to add calculated number to string.

Follow this to get number part-


=1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$9),1)),0),COUNT(1*MID(A1,ROW($1:$9),1)))

refer this link-

http://office.microsoft.com/en-us/excel-help/extracting-numbers-from-alphanumeric-strings-HA001154901.aspx

Asked By Cortney on 15-Jun-12 11:13 AM
Thank you for the responses. I did not want to auto number but this got my thoughts in order and I got there. I ended up trimming the alpha out and then adding it back in.