Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Merging an unknow number of records

Posted on 2014-04-21
5
Medium Priority
?
340 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
  • 2
  • 2
5 Comments
 
LVL 40

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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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 40

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

972 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