Results 1 to 4 of 4
  1. #1
    MiscMe is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Posts
    1

    Multiple Rows from one comma delimited field

    I have a table that includes a Name field, and another field which indicates their fields of interest. The items in this field are comma delimited. For example:

    Name Interest
    Joe Hiking, Biking, Jogging
    Sue Biking, Walking
    Tom Hiking, Jogging

    Ultimately I need to create a report that will break down like this:

    HIKING


    Joe
    Tom

    BIKING
    Joe
    Sue

    JOGGING
    Joe
    Tom

    I'm guessing I first need a query that's going to create multiple records per NAME based on their various interests, but I can't figure out how to do that.

    Thanks for any help.

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    I'd say your first course of action would be to make a new table that holds all of the interest values. Then you would create a third table to associate the interests to the names, YouTube "access many-to-many relationship" and you'll find plenty of videos to walk you through the concept and process. After that generating your report would be trivial.

    BTW you probably don't want to name any field or object "name".

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You are dealing with a 3 table set up( and possibly more) that allows 1 Person to have more than 1 Interest and allows the same Interest to be had by multiple Person(s).

    TblPerson----->tblPersonHasInterest<-----tblInterest


    See this info on database design

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I suppose the example doesn't accurately reflect the situation. If the data set is limited (quantity wise) because this is a new db under construction then sure, the design is faulty and needs to be repaired. If the case is really that you have hundreds/thousands of records where the compound data was designed this way, you'll need a custom function that a query can call for each field. However, if the number of comma separated values varies, you'd have to be content with Nulls in some fields in some records.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 14
    Last Post: 03-01-2012, 02:39 PM
  2. Comma Delimited List Query/Report
    By scrapyard in forum Queries
    Replies: 3
    Last Post: 01-20-2012, 07:06 AM
  3. create comma delimited string from column in query
    By younggunnaz69 in forum Queries
    Replies: 2
    Last Post: 04-30-2011, 04:26 PM
  4. Replies: 3
    Last Post: 03-20-2011, 04:45 PM
  5. Parsing A Comma Delimited Field
    By AccessGeek in forum Import/Export Data
    Replies: 6
    Last Post: 02-03-2011, 01:52 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