4 Replies Latest reply on May 11, 2015 3:50 PM by philmodjunk

    Mailing label script

    Deenos

      Title

      Mailing label script

      Post

      Hi:

      This is the script i have to lay out the field on the label. The problem I'm having is getting is removing the comma if there is no data in the second address field. The label looks like this:

      253 W 35th Street, 6th Floor
      New York, NY 10001

      However, I do not want the comma to appear if there is not data in the second address field (apt, floor or unit data). This is the script I wrote. What am I missing?
       

      P_street & P_street & "," & Case( not IsEmpty( P_street) and not IsEmpty(P_city & P_state & P_zip ); "¶" ) &
      Trim(
       
         P_city & Case( not IsEmpty( P_city ) and not IsEmpty( P_state & P_zip ); " " ) &
          P_state & Case( not IsEmpty( P_state ) and not IsEmpty( P_zip ); " " ) &
          P_zip & Case( not IsEmpty( P_city & P_state & P_zip ) and not IsEmpty( P_country ); "¶" )
      ) &
      P_country

      Any help is greatly appreciated.

      Thanks

       

        • 1. Re: Mailing label script
          philmodjunk

          P_street & P_street & "," &

          Doesn't really make sense as it appears to refer to the same field twice. Perhaps there's a typo there?

          It also doesn't seem to match your sample output where you would appear to need:

          P_Street & ", " & P_Street2 & Case (...

          To get the results shown and
          P_Street & IF ( Not IsEmpty ( P_Street2 ) ; ", " & P_Street2 ) & Case (...

          To avoid the extra comma when P_Street2 is empty.

          • 2. Re: Mailing label script
            Deenos

            Sorry for the typo. This is the corrected script.

            P_street & P_street2 & "," & Case( not IsEmpty( P_street) and not IsEmpty(P_city & P_state & P_zip ); "¶" ) &
            Trim(
             
               P_city & Case( not IsEmpty( P_city ) and not IsEmpty( P_state & P_zip ); " " ) &
                P_state & Case( not IsEmpty( P_state ) and not IsEmpty( P_zip ); " " ) &
                P_zip & Case( not IsEmpty( P_city & P_state & P_zip ) and not IsEmpty( P_country ); "¶" )
            ) &
            P_country

            • 3. Re: Mailing label script
              SteveMartino

              You're script seems over complicated for labels.  Wouldn't you want to make sure that record had at least a street (address1), city, state and zip during data entry, before printing labels?

               

               

              • 4. Re: Mailing label script
                philmodjunk

                What you show as a calculation still would not put a comma between P_Street and P_Street2. Are you sure that's correct? Any chance that the comma is actually text in one of the fields?