This issue sounds familiar, but please read it to the end, as it has a twist to similar questions I found in this forum or elsewhere. I am using Access 2010 to build a simple app to create some code to execute in another system. Part of it is to convert number of records per user into a single record, with all user entries separated by comma. To illustrate, here is the sample of my input:
USER MBR
---- ----
USR1 DRG
USR1 ABC
USR1 XYZ
USR2 123A
USR2 ABS2
And I need it in this format:
USER MBR_LIST
----- ---------------
USR1 DRG, ABC, XYZ
USR2 123A, ABS2
So far, so familiar. I've used the code posted by Allen Brown back in 2008 (http://allenbrowne.com/func-concat.html), but I've run into an issue. The code works fine - when I debug it, I can see that my output string ("strOut") has all MBRs for a single user, as expected. Mind you, sometimes this string is over 7,000 char long. So, again following some great advice found around, I've created a table with the MBR_LIST field set to MEMO, and I execute Allen's function as:
INSERT INTO Table2 ( [USR], MBR_LIST )
SELECT B.USR, ConcatRelated("MBR","Table1","Table1.USR = '" & B.USR & "'","USR") AS Mbr_List
FROM (SELECT Table1.USR FROM Table1 GROUP BY Table1.USR) AS B;
(NOTE: the query is built as such to avoid doing Group By on the Memo field, which is known to be truncating the Memo field)
Still, after doing this, my MBR_LIST field in the table shows only 320 chars (?).
I even tried adding an empty row, as suggested in this post: MS Access Create Table is Truncating Memo Field, but with no success - the field still gets truncated to 320 chars:
INSERT INTO Table2 ( [USR], MBR_LIST )
SELECT B.USR, "" as Mbr_List
FROM [Table2] as B Where (False)
UNION ALL
SELECT B.USR, ConcatRelated("MBR","Table1","Table1.USR = '" & B.USR & "'","USR") AS Mbr_List
FROM (SELECT Table1.USR FROM Table1 GROUP BY Table1.USR) AS B;
As a last resort, using the MID() I've created 20 "chunks" of 300 chars each (Mbr_1 to Mbr_20) in my SELECT statement, and I got them all back fine. Then I wrapped this into another SELECT with those chunks concatenated (Mbr_1 & Mbr_2 & ... & Mbr_20) AS Mbr_LIST, and got - 320 chars!
Any ideas why and how to insert/display the full string created by the function?
Thanks, tribe