Welcome to SPN

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

Sign Up Now!
  1. Guest ji, please consider donating today!
      Become a Supporter    ::   Make a Contribution   
    Monthly Recurring Target: $300 :: Achieved: $95

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
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page