Results 1 to 7 of 7
  1. #1
    rkruis is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4

    Question Pivot/Combining multiple string into one field


    I have three tables, I'll describe my best below.
    Code:
    tblMaster
    ID | Model | CommentsIds
    1  | ford | 123; 124; 126;
    2  | chev | 323; 124
    3  | ford  | 111; 124
    
    tblComments
    ID   | CommentID
    1    | 123
    1    | 124
    1    | 126
    2    | 323
    2    | 124
    3    | 111
    3    | 124
    
    tblCommentDescriptions
    CommentID | Commentdescription
    123    | "Some string"
    124    | "Another String"
    125    | "String 3"
    126    | "string 4"
    127    | "String 5
    ... continues
    I left join tblMaster ID to tblComments ID
    I left join tblComments Comments to tblCommentDescriptions CommentID

    My result is like this
    1 | 123 | "Some string"
    1 | 124 | "Another String"
    1 | 126 | "string 4"

    How can I combine the CommentDescriptions using a query, into one field using tblMaster ID and unique?
    Such as
    1 | "Some string""Another String""string 4"

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    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
    rkruis is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4
    Thanks June7, however this will not work for me.
    I need to use functions that already exist within MS Access and I am creating this on the fly.

    Basically I have this. I have one master table, and one child table. I need all of the related records from one column in the child table into one column.
    Such as
    1, Value 1, Value 2, Value 3
    2, Value 1, Value 4, Value 7

    1 and 2 a two different records in the master table. Value 1-x are records joined from the chils.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If you provide database so I don't have to build tables I will test some ideas. Follow instructions at bottom of my post.
    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.

  5. #5
    rkruis is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4

    Smile

    Take a look at the query (Test)
    It returns these results.
    Code:
    1wTachometer
    1
    wSchool Bus Package
    1
    w/o School Bus Package
    1
    wMulti-Stage Damper


    I want
    :
    'w/ Tachometer' 'w/ School Bus Package' 'w/o School Bus Package' 'w/ Multi-Stage Damper' 
    Thanks for the help.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Consider:

    Revise test query:
    SELECT Comments.CommentCode, tempPartsProTable.Id, Comments.CommentText
    FROM (tempPartsProTable RIGHT JOIN tempPartsProCommentTable ON tempPartsProTable.Id = tempPartsProCommentTable.Id) RIGHT JOIN Comments ON tempPartsProCommentTable.CommentID = Comments.CommentCode
    ORDER BY tempPartsProTable.Id;

    Query1
    TRANSFORM First(test.CommentText) AS FirstOfCommentText
    SELECT test.Id
    FROM test
    GROUP BY test.Id
    PIVOT test.CommentCode;

    Query2
    SELECT Query1.Id, [11] & ", " & [22] & ", " & [33] & ", " & [44] & ", " & [55] & ", " & [66] & ", " & [77] AS Comments
    FROM Query1;
    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.

  7. #7
    rkruis is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4
    Thanks June7! This works just fine. I would like to be able to not show commas if a field is blank, but that is a later task.

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

Similar Threads

  1. Combining Multiple Records into one field
    By MFlood7356 in forum Queries
    Replies: 3
    Last Post: 06-30-2011, 12:49 PM
  2. Combining value in multiple rows into new field
    By stricklanpbs in forum Access
    Replies: 4
    Last Post: 05-05-2011, 11:29 AM
  3. Combining values of 2 columns into one string
    By LAazsx in forum Programming
    Replies: 1
    Last Post: 11-25-2010, 08:36 PM
  4. Replies: 15
    Last Post: 10-14-2010, 12:22 PM
  5. Multiple Plot Pivot Chart
    By Catch Wrestler in forum Reports
    Replies: 0
    Last Post: 06-21-2010, 10:17 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