Eliminating blank lines in Query and Table records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bigdaddrock
    New Member
    • May 2010
    • 67

    #1

    Eliminating blank lines in Query and Table records

    I have created an address field that consists of Address1; Address2; City, State and Zip. When all are populated this would create a three line record. However, when there is no Address2, I would like it to appear as a two line record. What do I need to insert here? Here is what I have used to date:
    Expr: Address1 & Chr(13) & Chr(10) & Address2 & Chr(13) & Chr(10) & City & ', ' & State & ' ' & Zip

    In Reports I have used the Trim function, but that does not seem to work in Queries and Tables.

    Any suggestions??
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Bigdaddrock
    I have created an address field that consists of Address1; Address2; City, State and Zip. When all are populated this would create a three line record. However, when there is no Address2, I would like it to appear as a two line record. What do I need to insert here? Here is what I have used to date:
    Expr: Address1 & Chr(13) & Chr(10) & Address2 & Chr(13) & Chr(10) & City & ', ' & State & ' ' & Zip

    In Reports I have used the Trim function, but that does not seem to work in Queries and Tables.

    Any suggestions??
    Code:
    Expr: [Address1] & IIf(IsNull([Address2]),"",Chr(13) & Chr(10) & [Address2]) & Chr(13) & Chr(10) & [City] & ', ' & [State] & ' ' & [Zip]

    Comment

    • ChipR
      Recognized Expert Top Contributor
      • Jul 2008
      • 1289

      #3
      You could use something similar to:
      Code:
      Expr: Address1 & Chr(13) & Chr(10) & 
        IIf(IsNull(Address2),"", Address2 & Chr(13) & Chr(10)) & 
        City & ', ' & State & " " & Zip
      If no Address2 means the field is null. If it's an empty string, you would use
      Code:
        IIf(Address2="",...
      Last edited by ChipR; May 28 '10, 06:37 PM. Reason: missed an &

      Comment

      Working...