Help Splitting text fields

Discussion in 'MS Access' started by Hellojames, Nov 1, 2006.

  1. Hellojames

    Hellojames New Member

    Joined:
    Nov 1, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Little help?

    I have a long text field in a database which I need to split after 40 charaters at the next space.

    e.g
    from this:
    This is a long text field

    to this:
    this is a long
    text field

    not this:
    this is a long te
    xt field

    anyone any ideas??

    :confused: Thanks
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Refer [thread=1060]Split text field[/thread]. I am sure it will be of help to you.
     
  3. Hellojames

    Hellojames New Member

    Joined:
    Nov 1, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Yeah it was. But I have tried modifying the code so that it would not cut off mid word but I couldn't if I take off the -2 it takes the first word out of the text field.

    What I need is to find the 9th space in the field and cut from there.

    Any idea

    Thanks
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    There are quite a few string functions like
    Asc
    Format (with Strings)
    Mid
    Str
    Chr
    LCase
    Replace
    StrConv
    Concat with & Left Right Trim
    CurDir
    Len
    RTrim
    UCase
    Instr
    LTrim
    Space

    Use them to split the string of your field.
     
  5. Hellojames

    Hellojames New Member

    Joined:
    Nov 1, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi Shabbir

    You where right the first time. When I looked again then looked at the function of 'instr' I found I could specify how many characters along I wanted to start from then find a space. I had trouble getting the right hand section but fixed that using 'mid'.

    Thanks a lot
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice