How to concatenate multiple records from one table and display on a form

MilaK

Registered User.
Local time
Today, 09:57
Joined
Feb 9, 2015
Messages
285
Hello,

I would like to concatenate multiple related records from one table and display them on a form (please see the attached example).

Is there a way to do this without creating another table? If so, how?

Thanks, Mila
 

Attachments

  • table_example.JPG
    table_example.JPG
    37.1 KB · Views: 116
  • form_example.JPG
    form_example.JPG
    22.2 KB · Views: 102
The described function only takes in one field as the parameter. I would like to concatenate three fields for related records. Can this be done in Access? Thanks
 
Last edited:
Not so, as noted in the link:

Any valid WHERE clause is permitted

so you simply need to provide that. In your case, two fields separated by And.
 
Oh, and it should be easy to modify it to return more than one field.
 
I'd say to use whichever you're more comfortable with.
 
I’ve tried the other function that uses ADOBD connection but got an error message on ADODB.Connection that it couldn’t find the connection.

Allen Browne’s function produces an output, however, I’m not sure how to modify the function to get the desired output.

Here is the query that executed:

Code:
SELECT tbl_failed_amplicons.run_name, tbl_failed_amplicons.sample_name, ConcatRelated("gene","tbl_failed_amplicons","[sample_id] = """ & [sample_id] & """") AS Expr2, [gene] & "  " & [exon] & "  " & [depth] AS Exp3 FROM tbl_failed_amplicons;
(please see screenshot of the output)

It returns only genes string together and I would like to string [gene] & [exon] & [depth].

I’ve tried to add additional parameters to “where” clause "[sample_id] = """ & [sample_id] And "[gene] = """ & [gene] but it didn’t work. I’ve crashed Access several times and had to terminate the process.

Could you please suggest how to modify the where clause to get the desired output? Thanks, Mila
 

Attachments

  • Output_fa.jpg
    Output_fa.jpg
    28.8 KB · Views: 97
Ok, I solved it. I used two queries:

First:

Code:
SELECT tbl_failed_amplicons.sample_name, tbl_failed_amplicons.run_name, tbl_failed_amplicons.sample_id, [gene] & "  " & [exon] & "  " & [depth] AS Exp
FROM tbl_failed_amplicons;

Second:

Code:
SELECT Distinct ConcatRelated("Exp","qry_first_failed_amps","[sample_id] = """ & [sample_id] & """") AS Expr2
FROM qry_first_failed_amps;

Thanks
 
Glad you got it working.
 

Users who are viewing this thread

Back
Top Bottom