View Single Post
  #1  
Old March 3rd, 2010, 11:43 PM posted to microsoft.public.access.queries
QB
external usenet poster
 
Posts: 150
Default Concatenate multiple records

I have a table to enter contact information where each contact is assigned a
random id no. That said it is possible to also associate a Family id no so
you can link members of the same family together. I now need to pull a
singular list by family id with the relevant info combining multiple records
together and am lost on the how-to do it.

Basic Table Structure
Table Name: C1
Table Fields: ID, M_MNBR, M_TITLE, M_LNAME, M_FNAME, C_NAME, M_ADDR, ...

The ID is the PK and the M_MNBR is the family id.

I need to pull the a list
C_NAME, M_TITLE, M_FNAME, M_LNAME, M_ADDR, ...
but, and you knew there'd be a twist. I need to always group by the Title =
"Mr".

Therefore, if in a given family there is an entry for Mr John Smith and
another for Mrs Joan Smith I need it to return a concatenated C_Name Mr John
Smith and Mrs Joan Smith and then the rest of the data pertaining to only Mr
John Smith.

If in the case there is no Mr, then give the Mrs info, and vice-versa.

A concrete example
ID, M_MNBR, M_TITLE, M_LNAME, M_FNAME, C_NAME, M_ADDR, ...
1, 10001, Mr, Smith, John, Mr John Smith,...
2, 13092, Mrs, Libeler, Lilian, Mrs Lilian Libeler,...
3, 14560, Dr, Krawl, David, Dr David Krawl,...
4, 10001, Mrs, Smith, Gwen, Mrs Gwen Smith,...

The query would return
Mr John Smith and Mrs Gwen Smith, Mr, Smith, John, ...
Mrs Lilian Libeler, Mrs, Libeler, Lilian, ...
Dr David Krawl, Dr, Krawl, David, ...

Can this be done and how?

Thank you for the help,

QB