Skip to content
Advertisement

Combine cells in access separated by comma

I am new to access and coding. I have a sheet comprising of huge data. I want some specified data in Access by running a query or VBA. What I want is to combine the data based on a column and each data separated by a comma. I am pasting the example of the sheet below:

Input sheet

1

Output data enter image description here

I tried to use COMMON but with no luck. Please help.

Advertisement

Answer

Using Allen Browne ConcatRelated function (often referenced, start with Access: ConcatRelated works on a table, but not on a query) with non-normalized data structure:

Data structure can be normalized with UNION query.

Then producing desired output will involve two more queries, each calling ConcatRelated function.

Query1:

Query2:

Advantages of normalized data is the last 2 queries don’t have to be modified regardless of how many products are involved and ConcatRelated function is not referenced in query as often. With non-normalized data, if you add more product columns, query will have to be modified to call function again for each. Normalize table structure and UNION query can be eliminated.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement