In Access 2010 I've come across a need to concatenate fields from one column in one table into a single, comma delmited value in another field in the same table (or in another table if I absolutely must).
I've been working on an access database and have hit a wall after MANY hours of work and being THAT close to wrapping up my work.
I've read much on how todo this and it seems
Allen Browne has it licked I've written the module as instructed and that comiles just fine. I've had many other different errors that I've gotten past and am down to getting a syntax error.
I have a table called tbl_phoneSources. The table is currently laid out like this:
Phone LastName Sources
__________________________
5552515392 Gates Source4
5552515392 Gates Source2
5552515392 Gates Source1
5552201356 Ellison Source3
5552201356 Ellison Source1
5652201356 Jobs Source4
5652201356 Jobs Source1
I want it to become:
Phone LastName Sources
_________________________________________
5552515392 Gates Source4, Source2, Source1
5552201356 Ellison Source3, Source1
5652201356 Jobs Source4,Source1
After creating the module I have finally come down to using this expression in a fourth AS field in my query. Despite seeing MANY examples illustrating very much the same thing I want to do I just can't get past my syntax errors.
Here's what seems to work for most who also have issues:
ConcatRelated("source","tbl_phoneSources","[phone] = #" & [phone] & "# AND [lastName] = '" & [lastName] & "'")
Did I make a typo? Do I just not understand this?
In the description of the arguments it says:
3.Thirdly, supply the filter to limit the function to the desired values. This will normally be of the form:
"[ForeignKeyFieldName] = " & [PrimaryKeyFieldName]
If the foreign key field is Text (not Number), include quote marks as delimiters, e.g.:
"[ForeignKeyFieldName] = """ & [PrimaryKeyFieldName] & """"
...and I normally store phone numbers as text - which would require (escaped) double quotes.
posted by pompomtom at 6:03 PM on July 25, 2012