Hi Bruno,
here is some code written by John Viescas:
extract the "nth" part of a string based on the delimiter you supply.
Public Function ParseString( strIn As String, _
Optional intPart As Integer = 1, _
Optional strChar As String = " ") As String
'----------- --------- --------- --------- --------- --------- --
' Inputs: String to parse, Part to return, Delimiter
' Outputs: The "nth" part or "chunk" of the string
' Created By: JLV 05/15/2007
' Last Revised: JLV 05/15/2007
'----------- --------- --------- --------- --------- --------- --
' strIn - the string to parse
' intPart - the part you want returned;
' default is 1 if you don't supply it
' strChar - the delimiter character;
' default is a blank if you don't supply it
' NOTE: This is a rewrite of Parse using the Split function
' Place to put the result
Dim varStrings As Variant
' Internal variable for part and delimiter character
Dim intP As Integer, strDelim As String
'Get the position number
intP = intPart
' Make sure it's >= 1
If intP < 0 Then intP = 1
' Get the delimiter
strDelim = Left(strChar, 1)
' Now parse it
varStrings = Split(strIn, strDelim)
' Check that position exists in array
If intP > UBound(varStrings) + 1 Then
' Ooops - return empty string
ParseString = ""
Else
' Return the "nth" piece
ParseString = varStrings(intP - 1)
End If
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~`
Here are the directions:
Put the ParseString code in a general module. Compile and Save
In a query, to display the second part of a string separated by spaces
in a Select Query, use:
field --> PartOne: ParseString( [MyStringField] , 1, ",")
field --> PartTwo: ParseString( [MyStringField] , 2, ",")
etc
Warm Regards,
Crystal
remote programming and training
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
*
have an awesome day
*