Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Merging an unknow number of records

Posted on 2014-04-21
5
Medium Priority
?
338 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 39

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 39

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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