Results 1 to 5 of 5
  1. #1
    Subs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2013
    Posts
    5

    Combining duplicate records

    Beginner question: I receive data in CSVs, and import them into access 2007 to generate reports. For one of the tables, I need to be able to combine records with the same ticket number into a single line like below.

    Current
    0001 CI1
    0001 CI2
    0001 CI4
    0002 CI2
    0002 CI3
    0003 CI4

    Goal
    0001 CI1, CI2, CI4
    0002 CI2, CI3
    0003 CI4

    What is the easiest way to do this?

    Thank you.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I hope this is for a report.
    You shouldn't have the table in the "Goal" structure - leave the table in the "Current" structure. If you need to see it like the "Goal", use a query and base your form/report off of the query.

    Allen Browne has an example and code at:
    http://allenbrowne.com/func-concat.html

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Given this table layout for your imported data:
    Code:
    tblTickets
       Field Name  Field Type      example
       TickPK      Autokey    (assigned by system)
       TickID      Number     0001
       TickItem    Text       CI1
    Something like this will give you your requested results:
    Code:
    Transform First(TickItem) as TheItem
    SELECT TickID
    FROM
      (SELECT T1.TickID, T1.TickItem, T1.TickPK,  Count(T2.TickPK) As MyCount
      FROM tblTickets as T1 INNER JOIN tblTickets AS T2
      ON T1.TickID = T2.TickID 
      WHERE T1.TickPK >= T2.TickPK
      GROUP BY T1.TickID, T1.TickITem, T1.TickPK)
    GROUP BY TickID
    PIVOT "Item" & MyCount;

  4. #4
    Subs is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2013
    Posts
    5
    Thank you both. The concat function was exactly what I was looking for, and the other solution will help with another issue I was trying to figure out.

  5. #5
    Cassim is offline Novice
    Windows 8 Access 2007
    Join Date
    Nov 2013
    Posts
    6
    I managed to use it too...:-)

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

Similar Threads

  1. Combining Rows with Duplicate Values
    By julia.ranauro in forum Access
    Replies: 8
    Last Post: 06-18-2013, 07:54 AM
  2. combining records(rows)
    By pradeep.sands in forum Queries
    Replies: 4
    Last Post: 06-13-2013, 12:19 PM
  3. Combining Records
    By admessing in forum Queries
    Replies: 2
    Last Post: 12-15-2011, 05:41 PM
  4. Query for combining records
    By alpinegroove in forum Queries
    Replies: 6
    Last Post: 01-28-2011, 07:29 AM
  5. combining field from two records into one
    By RedGoneWILD in forum Queries
    Replies: 8
    Last Post: 07-13-2010, 09:47 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