Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Parse Space Delimited Text

Discussion in 'Information Technology' started by Victor, Jul 28, 2006.

  1. Victor

    Victor
    Expand Collapse
    Guest

    Can someone help me on parsing a space delimited string within a text field?
    There is no exact number of segments within each record. Example:
    Record 1 = "XXX ZZZZZ YYYY dddd"
    Record 2 = "XXX ZZ"
    Record 2 = "XXXX ZZZZ MMMM"
    I need to place each block of text into their own Field (Field1, Field2,
    field3........)
    thanks
     
  2. Loading...

    Similar Threads Forum Date
    Sikhi Gurdwaras Throw Open Their Spaces, Langar For Stranded Commuters In Haryana Sikh Sikhi Sikhism Feb 23, 2016
    SciTech Urgent Need to Remove Space Debris Breaking News Apr 25, 2013
    India Panthic space shrinking within Akali Dal; more Hindus for parliament Breaking News Mar 28, 2013
    Prayer / Simran Space Questions and Answers Jun 1, 2012
    SciTech Stephen Hawking: Colonize Space or End the Human Race Breaking News Jan 9, 2012

  3. Jeff Boyce

    Jeff Boyce
    Expand Collapse
    Guest

    Victor

    One approach might be to do the parsing in Excel, then import the data.

    Regards

    Jeff Boyce
    Microsoft Office/Access MVP


    "Victor" <Victor@discussions.microsoft.com> wrote in message
    news:6F933403-597B-49C7-A36F-52DAC1A84710@microsoft.com...
    > Can someone help me on parsing a space delimited string within a text
    > field?
    > There is no exact number of segments within each record. Example:
    > Record 1 = "XXX ZZZZZ YYYY dddd"
    > Record 2 = "XXX ZZ"
    > Record 2 = "XXXX ZZZZ MMMM"
    > I need to place each block of text into their own Field (Field1, Field2,
    > field3........)
    > thanks
     
  4. Ofer Cohen

    Ofer Cohen
    Expand Collapse
    Guest

    For the example I created a table (TableName) with fields (FieldName -
    contain the full string, Field1 To Field6)

    The function will split the maon string into parts, and insert each part to
    a seperate field
    ==============================
    Function SetString()
    On Error GoTo SetString_Err
    Dim DB As DAO.Database, MyRec As DAO.Recordset, I As Integer


    Set DB = CurrentDb
    Set MyRec = DB.OpenRecordset("Select * From TableName")
    While Not MyRec.EOF
    MyRec.Edit
    ' loop through the fields, change the loop to fit your needs
    For I = 1 To 6
    ' Split the values
    MyRec("Field" & I) = Split(MyRec!FieldName, " ")(I - 1)
    Next I
    MyRec.Update
    MyRec.MoveNext
    Wend

    Exit Function
    SetString_Err:
    If Err = 9 Then
    Resume Next
    Else
    MsgBox Error
    End If
    End Function
    ==============================
    --
    Good Luck
    BS"D


    "Victor" wrote:

    > Can someone help me on parsing a space delimited string within a text field?
    > There is no exact number of segments within each record. Example:
    > Record 1 = "XXX ZZZZZ YYYY dddd"
    > Record 2 = "XXX ZZ"
    > Record 2 = "XXXX ZZZZ MMMM"
    > I need to place each block of text into their own Field (Field1, Field2,
    > field3........)
    > thanks
     

Share This Page