EzGoingKev
Registered User.
- Local time
- Today, 13:15
- Joined
- Nov 8, 2019
- Messages
- 188
I am using Allen Browne's code here.
In several queries I am concatenating data from tables/other queries and the data I want to concatenate is in there multiple times. To do it in one step I changed Allen's code here:
to this
It has been working fine for years. Now I have to concatenate some data and it has to ordered by two fields. I added the two field names into my ConcatRelated statement and got an error when I went to run the query - Error 3093: ORDER BY clause ([First Field Name]) conflicts with DISTINCT.
I removed the DISTINCT from Allen's code and the query runs fine. Everything is in order. Now when I run the other queries I have dups in the concatenated field.
My level of knowledge gives me two solutions.
#1 - Keep Allen's code SELECT and not SELECT DISTINCT. To keep from getting dups I would first need to do a query that outputs distinct values. Then concatenate off the query.
#2 - Set up two functions with Allen's code, one with SELECT and one with SELECT DISTINCT to make ConcatRelated and ConcatRelatedDistinct functions. The situation would dictate which one I would use.
You guys have A LOT more knowledge than I do. Is there another easier solution?
In several queries I am concatenating data from tables/other queries and the data I want to concatenate is in there multiple times. To do it in one step I changed Allen's code here:
Code:
strSql = "SELECT " & strField & " FROM " & strTable
to this
Code:
strSql = "SELECT DISTINCT" & strField & " FROM " & strTable
It has been working fine for years. Now I have to concatenate some data and it has to ordered by two fields. I added the two field names into my ConcatRelated statement and got an error when I went to run the query - Error 3093: ORDER BY clause ([First Field Name]) conflicts with DISTINCT.
I removed the DISTINCT from Allen's code and the query runs fine. Everything is in order. Now when I run the other queries I have dups in the concatenated field.
My level of knowledge gives me two solutions.
#1 - Keep Allen's code SELECT and not SELECT DISTINCT. To keep from getting dups I would first need to do a query that outputs distinct values. Then concatenate off the query.
#2 - Set up two functions with Allen's code, one with SELECT and one with SELECT DISTINCT to make ConcatRelated and ConcatRelatedDistinct functions. The situation would dictate which one I would use.
You guys have A LOT more knowledge than I do. Is there another easier solution?