I'm trying to combine an unknown amount of text together in a query. Basically the opposite of parsing a field.
As an example, let say I have the following table with 2 columns (code and message) with the following records.
code message
----- ------
AA neat
AA great
BB exciting
BB dull
BB neat
CC great
This is the recordset I like to present.
code message
----- -----------
AA neat, great
BB exciting, dull, neat
CC great
Does anyone have a suggestion for accomplishing this?
I'm familiar with crosstabs and know can I do the following:
TRANSFORM Min(TestTable.message) AS MinOfmessage
SELECT TestTable.code
FROM TestTable
GROUP BY TestTable.code
PIVOT "message" & DCount("code","TestTable","message <='" & [message] & "' AND code = '" &
As an example, let say I have the following table with 2 columns (code and message) with the following records.
code message
----- ------
AA neat
AA great
BB exciting
BB dull
BB neat
CC great
This is the recordset I like to present.
code message
----- -----------
AA neat, great
BB exciting, dull, neat
CC great
Does anyone have a suggestion for accomplishing this?
I'm familiar with crosstabs and know can I do the following:
TRANSFORM Min(TestTable.message) AS MinOfmessage
SELECT TestTable.code
FROM TestTable
GROUP BY TestTable.code
PIVOT "message" & DCount("code","TestTable","message <='" & [message] & "' AND code = '" &
Code:
& "'");
And get this recordset:
code message1 message2 message3
---- ----------- ----------- ------------
AA great neat
BB dull exciting neat
CC great
Which I can then concatenate by using message1 & iif(message2 <> "",) ", " & message2, "") & iif(message3 <> "",) ", " & message3, "")
The only problem with this crosstab approach is that I won't know how many messsage there are. There many be 1, 2, 3 or 10. Is there a more flexible/dynamic method? Is the JOIN/SPLIT function a possibility?
I appreciate any thoughts! Thanks in advance for the assistance.