Need to return only characters (not numbers) in a string

jlaserso

JimLSeattle
Local time
Today, 09:17
Joined
Sep 18, 2008
Messages
2
We have data in a table that looks as follows:
RN00123450
LPN097777771
ARRT1190
RT0023334
(lots more with different starting letters)

We would like to get just the character portion of the string in a separate field so we get the following in a separate field in our query:

RN
LPN
ARRT
RT

We've looked at lots of the standard functions for string handling and haven't found it. Perhaps we have to use VB although I am not versed in it. If anyone can share how to do it that would be great. I've googled this a bunch.
 
HI -

Copy/paste this to a standard module, then call as shown
in the example:

Code:
Function fSaveFirstAlpha(pPostCode As String) As String
'*******************************************
'Purpose:   Return the first nth contiguous
'           alpha characters in a string
'Coded by:  raskew
'Inputs:    (1) ? fSaveFirstAlpha("GL24 6TY")
'           (2) ? fSaveFirstAlpha("G1 4TH")
'           (3) ? fSaveFirstAlpha("GABC1 4TH")
'           (4) ? fSaveFirstAlpha("4G1 4TH")

'Outputs:   (1) GL
'           (2) G
'           (3) GABC
'           (4)
'*******************************************

Dim i       As Integer
Dim n       As Integer
Dim strHold As String


    strHold = pPostCode
    n = Len(strHold)
    i = 1
    Do While Asc(Mid(strHold, i, 1)) >= 65 And Asc(Mid(strHold, i, 1)) <= 90 And i <= n
       i = i + 1
    Loop
    fSaveFirstAlpha = Mid(strHold, 1, i - 1)
    
End Function

HTH - Bob
 
Bob, This worked great. Thank you so much!
 

Users who are viewing this thread

Back
Top Bottom