Results 1 to 4 of 4
  1. #1
    Ganymede is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Dec 2011
    Posts
    116

    Concatenate Query Results

    Hi. I'm not quite sure how to describe what I'm trying to achieve without an example. So here goes.

    Say I have a table that looks like this.
    Species Breed
    Cat Siamese
    Cat Ragdoll
    Dog Poodle
    Cat Sphynx
    Dog Bulldog
    Dog German Shepard
    Dog Golden Retriever


    I want to run a query from that table that looks like this
    Species Breeds
    Cat Siamiese, Ragdoll, Spynx
    Dog Poodle, Bulldog, German Shepard, Golden Retriever

    So basiclaly in this example I collapsed all speices into one row and concatenated the results of the breeds column.



    Is that something that can be done programatically in access?

  2. #2
    Ganymede is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Dec 2011
    Posts
    116
    Please disregard. I think I figured it out.

    http://allenbrowne.com/func-concat.html

  3. #3
    Gustav's Avatar
    Gustav is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2025
    Posts
    32
    If this a larger table and you want speed, you can use my function DJoin found at my repository at GitHub: https://github.com/GustavBrock/VBA.DJoin

    Code:
    SELECT Species, DJoin("Breed","Animals","Species = '" & [Species] & "'",", ") AS Breeds
    FROM Animals
    GROUP BY Species;
    Click image for larger version. 

Name:	Skærmbillede 2025-04-13 083125.png 
Views:	10 
Size:	4.9 KB 
ID:	52965
    Last edited by Gustav; 04-13-2025 at 08:15 AM. Reason: Image gone

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,552
    Last edited by Welshgasman; 04-13-2025 at 07:12 AM.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 6
    Last Post: 04-12-2019, 07:26 AM
  2. Replies: 3
    Last Post: 07-02-2015, 02:17 PM
  3. Concatenate Results of Query
    By bryan0 in forum Queries
    Replies: 3
    Last Post: 03-02-2014, 12:23 AM
  4. Using a query to concatenate data
    By ocampod in forum Queries
    Replies: 15
    Last Post: 03-20-2012, 08:11 AM
  5. Concatenate Query Results
    By Rawb in forum Queries
    Replies: 6
    Last Post: 01-19-2011, 07:50 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