parsing a long ID into separate fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Annerb
    New Member
    • Jan 2013
    • 11

    parsing a long ID into separate fields

    I am attempting to separate a unique ID into separate fields (columns) using the Right/Left command. I am able to do this when I specify to use the rightmost or leftmost characters but am getting an error message when I specify to take the 2 characters starting from the third character in. Here is an example of my unique ID: 2011_1_HeronSS_ 3

    Using Right([unique_ID],1) returns "3". That is what I want.
    However,
    Using Right([unique_ID],3,2)gives me an error message "The expression you entered has a function containing the wrong number of arguments" instead of the "SS" that I need.

    I have used the example from the Access manual to base my formula off of and have formatted it EXACTLY how the example is in the book. Why is Access seeing this simple command as wrong? Thanks for any help/suggestions!!
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    You need the Mid() function to grab a portion of a string from the middle of another string. So it would be:
    Code:
    Mid(unique_ID,11,2)
    You might have to edit the numbers if I mis-counted, but that should be easy. Here are some links for the Left(), Right(), and Mid() functions:
    Left Function
    Right Function
    Mid Function

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      If the left part of the string can be variable length, use a Right() and then a Left().

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32653

        #4
        Originally posted by AnneRB
        AnneRB:
        I have used the example from the Access manual to base my formula off of and have formatted it EXACTLY how the example is in the book
        I suggest you check the manual again closely Anne. The parameters you list are certainly valid looking for the Mid() function, but both the Left() and Right() functions take only two parameters. If the manual actually has an example of using three parameters with either the Left() or Right() functions, then it is simply wrong.

        To find the best (most appropriate) way to handle extracting data from your long string ID field would certainly require a clearer understanding of exactly how it's constructed. If all the sections are always exactly the same length then it's more straightforward . If not, then Rabbit's suggestion of using Left() or Right() embedded within the other is likely to be necessary. Even that may not be reliable enough. Only a full understanding will determine this.

        Comment

        Working...