Results 1 to 6 of 6
  1. #1
    securitywyrm is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    97

    Query with line break divided lines of data?

    I have a contacts database that has position and program titles for many individuals. Some people have dozens of positions, some just have one. I want to create a query that would output something like this

    Contact email | Program and position title (Line break) Program and position title (line break) Program and position title)
    Live example
    John Smith | Nephrology Program coordinator (Line break) Rheumatology Site Director (Line break) Rheumatology TMS Coordinator
    Jane Doe | Rheumatology program coordinator (Line break) Cardiology Site director (Line break) Urology program coordinator



    That way I can just feed that into a mail merge document and email each person a list of their current positions. Is this possible with SQL queries?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Yes, it is, look at the Join function (https://msdn.microsoft.com/en-us/vba.../join-function). I also have a sample custom function on my site (http://forestbyte.com/vba-code-samples/) called JoinFromArray that I use in queries. I assume the positions are in a different table with a ContactID as a foreign key.



    Cheers,
    Vlad

  3. #3
    securitywyrm is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    97
    That's some amazing code. It's a few orders of magntiude above what I can do, but I THINK I understand WHAT it does, if you could confirm.

    Let's say we have a table of "Names and email addresses" and a table of "Names, position title and program name."

    This function will let you take the output of the second query (Name, position title, program name), and merge it into a column output of the first query. Thus it would be "Name | Email address | Array from second query matching name value"

    Is that correct?

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Yes, you pass it the foreign key field name, the value (from the first query), the name of the second query, the delimiter, etc.

  5. #5
    securitywyrm is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    97
    Quote Originally Posted by Gicu View Post
    Yes, you pass it the foreign key field name, the value (from the first query), the name of the second query, the delimiter, etc.
    Fantastic. I sent in an email requesting a quote from your site, seems like you have all the code I need implemented into these databases.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Is QBFMailingList the query where you want the new field?

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

Similar Threads

  1. Line Break in Textbox
    By alyon in forum Access
    Replies: 8
    Last Post: 02-16-2015, 10:21 AM
  2. Replies: 5
    Last Post: 09-11-2014, 10:25 AM
  3. How to make a subform break line?
    By newyorkyankee in forum Forms
    Replies: 1
    Last Post: 11-01-2012, 12:18 PM
  4. How to break lines in memo fields?
    By newyorkyankee in forum Access
    Replies: 2
    Last Post: 05-11-2012, 02:56 PM
  5. Line Break in Rich Textbox
    By alyon in forum Access
    Replies: 2
    Last Post: 08-15-2011, 01:07 PM

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