Results 1 to 5 of 5
  1. #1
    gcbeldar is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    May 2017
    Posts
    14

    Conditional Concatenating Text Fields in a Report

    Good Morning,

    Have Database Fields; Address1, Address2, Address3, Address4.

    Designed a Report with One Text Box linked as;
    =[Address1] & "," & " " & [Address2] & "," & " " & [Address3] & "," & " " & [Address4]

    Now wanted 2 requirements;
    1. If [AddressX] is blank, char "," should not print, which is printing with the above code.
    2. How print "On the next line after printing [Address1] and [Address2]" ?



    Thanks in Advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Try something like:

    =[Address1] & ", " + [Address2] & Chr(13) & Chr(10) & ", " + [Address3] & ", " + [Address4]

    Otherwise, build a custom VBA function to construct the string.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Apr 2017
    Posts
    1,679
    Expanding June7's formula
    =[Address1] & ", " + [Address2] & Chr(13) & Chr(10) & Iif(Nz( [Address3],"")="","",", ") & Nz([Address3],"") & ", " + [Address4]

  4. #4
    gcbeldar is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    May 2017
    Posts
    14
    First Thanks to ALL,

  5. #5
    gcbeldar is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    May 2017
    Posts
    14
    Quote Originally Posted by ArviLaanemets View Post
    Expanding June7's formula
    =[Address1] & ", " + [Address2] & Chr(13) & Chr(10) & Iif(Nz( [Address3],"")="","",", ") & Nz([Address3],"") & ", " + [Address4]
    Dear Sir,

    Thanks and this code is working as per my requirement,
    =[HAddress1] & IIf([HAddress1],", "," ") & Chr(13) & Chr(10) & [HAddress2] & IIf([HAddress2],", "," ")

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Conditional Formatting or VBA for Report Fields
    By GoldenOrb in forum Reports
    Replies: 3
    Last Post: 10-24-2013, 03:35 PM
  2. Replies: 4
    Last Post: 10-14-2012, 03:34 AM
  3. Conditional text box for two fields
    By hawkins in forum Access
    Replies: 9
    Last Post: 08-16-2011, 12:21 PM
  4. Concatenating (2x unbound into bound text box)
    By justinwright in forum Programming
    Replies: 1
    Last Post: 08-19-2010, 08:11 AM
  5. Concatenating many fields into one field
    By olidav911 in forum Programming
    Replies: 1
    Last Post: 08-13-2009, 05:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums