Results 1 to 5 of 5
  1. #1
    Falafa is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    6

    Concatenating Four Columns of Text in a Query

    I have a table [tblWritersGroups] within which are four columns of names: [GroupLeaderName], [AltGrpLeaderName1], [AltGrpLeaderName2] and [AltGrpLeaderName3].
    Click image for larger version. 

Name:	ExampleTable.jpg 
Views:	3 
Size:	55.7 KB 
ID:	9473

    I want to concatenate the names into one column with commas separating more than one name. A simple &", "& displays all three commas regardless of whether or not the three extra rows have names in them. How do I write a single query expression that will not display extra commas in rows with less than four names?


    Click image for larger version. 

Name:	ExampleQuery.jpg 
Views:	4 
Size:	103.3 KB 
ID:	9474
    Thanks in advance for any help............
    Attached Thumbnails Attached Thumbnails ExampleTable.jpg  

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Try:
    Group Leaders: IIf(Len(GroupLeaderName > 0), GroupLeaderName & ", ", "") & IIf(Len(AltGrpLeaderName1> 0), AltGrpLeaderName1& ", ", "") & IIf(Len(AltGrpLeaderName2> 0), AltGrpLeaderName2& ", ", "") & IIf(Len(AltGrpLeaderName3> 0), AltGrpLeaderName3& ", ", "")

    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Falafa is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    6
    I entered that expression and it displays "#Error."
    Click image for larger version. 

Name:	NewExpression.jpg 
Views:	3 
Size:	95.4 KB 
ID:	9475 Click image for larger version. 

Name:	NewExpressionDisplay.jpg 
Views:	3 
Size:	53.1 KB 
ID:	9476
    What am I doing wrong? And, what does the abbreviation "Len" mean or stand for?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    OK, Try:
    Group Leaders: [GroupLeaderName] & IIf(Not IsNull([AltGrpLeaderName1]),", " & [AltGrpLeaderName1],"") & IIf(Not IsNull([AltGrpLeaderName2]),", " & [AltGrpLeaderName2],"") & IIf(Not IsNull([AltGrpLeaderName3]),", " & [AltGrpLeaderName3],"")
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Falafa is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    6
    Woohoo!!!!!! Perfect! That did it! THANK YOU SO MUCH!

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

Similar Threads

  1. Replies: 1
    Last Post: 06-08-2012, 11:14 AM
  2. Replies: 3
    Last Post: 03-30-2012, 10:50 AM
  3. Replies: 61
    Last Post: 03-14-2011, 03:29 AM
  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 from a table or query.
    By stephen c in forum Programming
    Replies: 3
    Last Post: 07-13-2009, 08:14 PM

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