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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seperate Text and Numbers 1

Status
Not open for further replies.

jcw5107

Technical User
Jan 31, 2007
66
US
I have searched & searched - to no avail...!!
I can't believe that my situation is different...!!
Anyhow..
I have a field in a table that I need to split up & seperate the numbers and text.
Example data:
9A/R
8 FT
8 AR
16ozA/R
What I'm after - in seperate fields:
9 A/R
8 FT
8 AR
16 ozA/R

Any suggestions or examples...??
Thanks in advance...!!
jcw5107
 




Hi,

I'd write a user defined function and use the function in my query. Past this in a Module...
Code:
Function GetValue(sVal As String, NumTxt As String)
    Dim i As Integer
    For i = 1 To Len(sVal)
        Select Case Mid(sVal, i, 1)
        Case "0" To "9"
            If UCase(NumTxt) = "NUM" Then
                GetValue = GetValue & Mid(sVal, i, 1)
            End If
        Case Else
            If UCase(NumTxt) = "TXT" Then
                GetValue = GetValue & Mid(sVal, i, 1)
            End If
        End Select
    Next
End Function
So in your query...
Code:
NumVal: GetValue([YourField],"NUM")
TxtVal: GetValue([YourField],"TXT")


Skip,

[glasses] [red][/red]
[tongue]
 
Skip,

Thank you so much..!! That is exactly what I was lookin' for. Thanks..!!
Star for ya..!!

jcw5107
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top