taking the last 'comma' off a text string.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mankney
    New Member
    • Mar 2013
    • 7

    taking the last 'comma' off a text string.

    I concatenated a groups of fields into one string field ignoring any 'null' values. Worked OK except when the last field in 'null' i get a comma. I've trimmed the field to eliminate all blanks and tried the variations of the following:
    Code:
    xx: IIf([x]=',',Right([NewDesc3],Len([NewDesc3])-1),[NewDesc3])
    *the value of 'x' is the last character of the field.
    I'm just working the the design view of Access 2007.
    It sounds simple enough be i'm having no luck
    Last edited by zmbd; Mar 12 '13, 08:40 PM. Reason: [Z{Please use the [CODE/] button to format posted code/html/sql - Please read the FAQ}]
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    You are close, but your 'X' needs to be the right function and the 'true' path needs the left function. Like this:
    Code:
    IIF(Right(NewDesc3, 1) = ',' ,
    Left(NewDesc3, Len(NewDesc3) - 1),
    NewDesc3)
    This tests for the right most character to see if it is a ,. If it is then it gets all the characters for the length of the string except the last one.

    Comment

    • mankney
      New Member
      • Mar 2013
      • 7

      #3
      You know it runs without error but doesn't display any result.

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        No matter what the data or only when there is a comma at the end or only if there isn't a comma at the end?

        Comment

        • mankney
          New Member
          • Mar 2013
          • 7

          #5
          Doesn't seem to matter just doesn't return any value. I have the boxed checked just doesn't show the column. Doesn't stop for a bad expression or return an #error.

          Shouldn't be this hard!

          Comment

          • Seth Schrock
            Recognized Expert Specialist
            • Dec 2010
            • 2965

            #6
            Create another field that just has
            Code:
            Right(NewDesc3, 1)
            make sure that gets what you want. Then do
            Code:
            Len(NewDesc3) - 1
            Keep working through all the individual steps and then start putting them together. Keep testing after each change and then let us know where/when it breaks.

            Comment

            Working...