Results 1 to 5 of 5
  1. #1
    markaschiff is offline Novice
    Windows 10 Office 365
    Join Date
    May 2022
    Posts
    1

    Consolidating records on many side of a one-to-many relationship into one row for mail merge

    Hi all,

    I'm trying to build a database to track interviews. I'm calling the interviewees participants. One interview may involve between 1 to 4 participants. Each participant will (over time) be involved in many interviews. I'm thinking of the following table structure:

    tblInterviews
    InterviewID
    InterviewDate
    InterviewStartTime
    InterviewStopTime
    InterviewOutcome

    tblParticipants
    ParticipantID


    ParticipantPrefix
    ParticipantFirstName
    ParticipantLastName
    ParticipantDOB

    tblInterviewsParticipants
    InterviewParticipantID
    InterviewID
    ParticipantID
    ParticipatingVia (i.e., Zoom, in person, phone)

    After each interview, I need to write a letter that has the following sentence: "I interviewed ParticipantID1, ParticipantID2... (up to 4 participants) on InterviewDate. The interview commenced at InterviewStartTime and concluded at InterviewStopTime..." I'm running into trouble doing this using Mail Merge and Word.

    Is there a query or some other way that I could output a table such that for each InterviewID in tblInterviewsParticipants, each related ParticipantID is put onto one row? For example, right now, the join table would look like:

    InterviewID1 ParticipantID1
    InterviewID1 ParticipantID2
    InterviewID2 ParticipantID1

    I need a table that looks like:

    InterviewID1 ParticipantID1 ParticipantID2
    InterviewID2 ParticipantID1, etc.

    Any assistance will be appreciated. FYI, I'm a newbie and unfortunately not versed in VBA.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Need VBA to build the CSV string. Review http://allenbrowne.com/func-concat.html.
    Call the function from query or textbox or VBA.

    Is Word merge really needed? Could an Access report provide adequate output?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Here is another function by theDBguy http://www.accessmvp.com/thedbguy/co...itle=simplecsv
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    usual method is to use a function something like the concat_related function here
    http://allenbrowne.com/func-concat.html

    your vba code might look something like

    dim myLetter as string
    myLetter=" "I interviewed " & concat_related(.....) & " on interview date"



  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,880
    I use Albert Kallal's Super Easy Word Merge routine to generate various documents.

    What I do is use a non-normalized table in a temporary database. I use a series of append queries to gather the data into that table and then just use "Select * from TempDB" to populate the merge fields.

    here's an old demo
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Consolidating records by 2 different fields
    By zippy483 in forum Access
    Replies: 3
    Last Post: 10-15-2020, 04:32 AM
  2. Replies: 3
    Last Post: 07-11-2019, 09:43 AM
  3. Replies: 15
    Last Post: 11-30-2012, 01:36 PM
  4. Consolidating Records
    By OldUser in forum Queries
    Replies: 2
    Last Post: 10-03-2011, 05:13 PM
  5. Multiple records side by side
    By Patience in forum Reports
    Replies: 8
    Last Post: 09-01-2010, 09:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums