Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

separating numbers from letters

Status
Not open for further replies.

wdbouk

Technical User
May 28, 2003
81
CA
Hi,

I have a column where the content is a mix of numbers followd by letters. such as 025816AK (always numbers followd by letters but the length of numbers and letters differ and not always 6 numbers to 2 letters).I am wondering if there is a way to let Access separate the numbers from letters because I am interested only with the observations that have common numbers. is there a way to do so ?
 
The VAL function may work for you
Code:
? VAL("025816AK")
 25816
but you will lose the leading zero (if one exists).
 
How are ya wdbouk . . .

Here's a function that returns the [blue]numeric part[/blue] as a string:
Code:
[blue]Public Function NumPart(usrDat As String) As String
   Dim txtNum As String, Idx As Long, NumLen As Long
   
   txtNum = CStr(Val(usrDat))
   Idx = InStr(1, usrDat, txtNum)
   NumLen = Len(txtNum)
   If Idx > 1 Then NumLen = NumLen + Idx - 1
      
    NumPart = Left(usrDat, NumLen)

End Function[/blue]
Calling the function:
Code:
[blue]   = NumPart("025816AK")[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top