Forum Discussion
crunchy
Jan 13, 2020Copper Contributor
Concat Help
Hello, I'm getting errors when I'm trying to follow along with the SQL code to combine items into one row. I want to remove duplicate Contract Numbers and combine them as below: This what I h...
Woldman
Sep 17, 2020Iron Contributor
Maybe you found a solution in the meantime, otherwise this could maybe help.
Your request could be solved with a VBA-function (ConcatRelated) that's developed by Allen Browne. I attached a file with the function. If you import this as a module in your database, you should be able to use the ConcatRelated-function in a query like this:
SELECT ConcatRelated("PID","ContractDetails") AS PID, Contract AS [Contract#], SUM([Pre-Tender]) AS [Pre-Tender SubTotal], SUM(Awarded) AS [Awarded SubTotal]
FROM ContractDetails
GROUP BY Contract;
This is the query output:
I named the table ContractDetails, but you can replace it with yours. Note that you have to replace it in the call to ConcatRelated() as well.
Hope it works.
Best wishes,
Tieme