Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2004
    Posts
    277

    Unanswered: trimming the last 4 characters off of a field

    how would i put this if say the field shows Player-LAX and another record is Player-BPT and I want to remove the - and everything after it which will always be 3 characters after the -

    I want it to show just Player

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by DackJaniels
    how would i put this if say the field shows Player-LAX and another record is Player-BPT and I want to remove the - and everything after it which will always be 3 characters after the -

    I want it to show just Player
    What is "it"? Is this to be permanent or just a display issue?
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Feb 2004
    Location
    Swindon, UK
    Posts
    86
    Try

    OutcomeValue = Left(Len(FieldValue)-4)
    "Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done."

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Mowgli212001's solution will work if there always 3 characters after the hypen, IE you are genuinely trying to remove the last 4 characters

    If not you will have to consider some code to search for the hypen & then truncate after (instr() & left$() functions may be of assistance

  5. #5
    Join Date
    Nov 2003
    Posts
    167
    If the field is variable length and you will always be looking for a "-" preceded by a space, you could also use the following:

    OutcomeValue: Left([FieldValue],InStr([FieldValue],'-')-2)

    If there is no space before the "-", change the '-2' to '-1'.
    Kit Lemmonds

  6. #6
    Join Date
    Dec 2004
    Posts
    277
    Quote Originally Posted by Mowgli212001
    Try

    OutcomeValue = Left(Len(FieldValue)-4)
    that is definitely along the line i was looking for but that is coming up with an error

  7. #7
    Join Date
    Feb 2004
    Location
    Swindon, UK
    Posts
    86
    Just a couple of questions.

    1.What version of Access are you using?
    2.What is the error message?
    "Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done."

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    it should read
    [OutcomeValue] = Left$([fieldvalue],Len([FieldValue])-4)

  9. #9
    Join Date
    Dec 2004
    Posts
    277
    Quote Originally Posted by onansalad
    If the field is variable length and you will always be looking for a "-" preceded by a space, you could also use the following:

    OutcomeValue: Left([FieldValue],InStr([FieldValue],'-')-2)

    If there is no space before the "-", change the '-2' to '-1'.
    Perfect!!

    Exactly what I was looking for

    Because our Carriers are all named [CarrierName]-WhatevertheTerminalIs

    So for the accounting purposes they have to be broken down to be [CarrierName]

    Thank you once again for help on this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •