Combine values from related rows into a single concatenated string value

This is easy using Allen Browne’s ConcatRelated() function. Copy the function from that web page and paste it into an Access standard code module.

Then this query will return what you asked for.

SELECT
    i.N_ID,
    i.F_Name,
    i.L_Name,
    ConcatRelated(
        "Course_ID",
        "tbl_Courses",
        "N_ID = '" & [N_ID] & "'"
        ) AS Course_IDs
FROM tbl_Instructors AS i;

Consider changing the data type of N_ID from text to numeric in both tables. If you do that, you don’t need the single quotes in the third argument to that ConcatRelated() expression.

"N_ID = " & [N_ID]

And whenever you need N_ID displayed with leading zeros, use a Format() expression.

Format(N_ID, "000")

Leave a Comment