Solved

Merging an unknow number of records

Posted on 2014-04-21
5
335 Views
Last Modified: 2014-04-21
I have a mastermember table in which each record represents a family. The key field is [membershipID]. I have a members table which represents individual people. The key field is [memberID]. Any number of people may represent a family. I need to develop a table which contains a single row for each family and each member of the family needs to be included.

I need this because I've been ask to produce a spreadsheet containing all family members which can be used in a mail merge.

Creating a query to select the [head_of_house] is simple but how do you select the other family members when there may be none, one or any number?

Using the members table I have the following fields.
membershipID ; used to group the family
memberID ; to identify each member of the family
membertype ; head, spouse, son, daughter

I know there needs to be a loop involved by I don't know how to execute it.
Loop through all [membertype = son] where [membershipID = head.membershipID] ?

Any suggestion on a concept, a direction to start?
Attached is a sample database and spreadsheet.
family.accdb
family.xlsx
0
Comment
Question by:Gary Samuels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 40012632
Here is a function written by Allen Browne that will do the concatenation for you.

http://allenbrowne.com/func-concat.html
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40012770
0
 

Author Comment

by:Gary Samuels
ID: 40013113
As instructed I inserted a new module which was named Module 2. I also added the function to the end of Module 1, and the Global Module.

I tried it but all I could get was "Undefined function 'ConcatRelated' in function".
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 40013156
The procedure needs to be in ONE and ONLY ONE module.  That is because the procedure MUST be public in order to be referenced from a query.  If multiple modules contain the same procedure name, you will get compile errors.

So,
1. Put the procedure  in ONE module.
2. Make sure the procedure is defined as Public.
3. Make sure everything compiles.
4. Make sure that there are no typos.
0
 

Author Closing Comment

by:Gary Samuels
ID: 40013183
It Worked.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question