SpaceCoastLife
asked on
Seperating text and numbers in a string
I'm looking for help separating text from numbers in an Access string. Example: "BURLINGTON TOWERS1000 BURLINGTON AVE N 603"
I need everything left of 1000 in it's own field.
There are a few thousand records with every combination of text and numbers in this table with no space between than.
I need everything left of 1000 in it's own field.
There are a few thousand records with every combination of text and numbers in this table with no space between than.
ASKER
I’ll give it a try first thing tomorrow. Thanks
This tiny function will pull the string:
Public Function LeftString(ByVal Value As String) As String
Dim Result As String
Dim Position As Long
For Position = 1 To Len(Value)
If Not IsNumeric(Mid(Value, Position, 1)) Then
Result = Left(Value, Position)
Else
Exit For
End If
Next
LeftString = Result
End Function
So, in your query it could be:Select *, LeftString(Nz([YourAddressField])) As Building From YourTable
ASKER
Gustav: Your code separates text and numeric values just as you said placing it in it's own field and that part is great but how do I now remove that same text from the Address field?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
with no space between thanIs there any character between them? Often there is a carriage return or line feed character that doesn't show up in a textbox or datasheet cell.
ASKER
Everything worked exactly like you said it would. Thank you!
You are welcome!
Open in new window
This will partition everything before the first digit into capture group 1, dropping trailing spaces (if any exist.)