Results 1 to 3 of 3
  1. #1
    joeromero87 is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Location
    Las Vegas, NV
    Posts
    1

    Grouping

    Hi, I've got a question that relates to reporting. I've got a database of client contact information (email, address, phone, etc.). I'd like to run a report that returns all addresses, emails, phone numbers for each client (some clients have multiple of each) without duplication. For a client with 2 addresses and 2 emails, my query returns the following:

    Client1 Address1 Email1
    Client1 Address1 Email2
    Client1 Address2 Email1
    Client1 Address2 Email2

    This is obviously not an ideal presentation. I've managed to accomplish the following with grouping:

    Client1
    Address1
    Email1
    Email2
    Address2
    Email1
    Email2



    But still, there is a duplication of the emails. I want a presentation like:

    Client1
    Address1
    Address2
    Email1
    Email2

    Is this possible? Any help would be appreciated.

    -Joe

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I think an appropriate table structure would be

    1 Client has 1 or many MailingAddresses
    1 Client has 0 or more Email Addtresses

    3 tables

    tblClient
    ClientID PK
    ClientFirstName
    ClientLastName
    ClientDOB
    other Client stuff

    tblMailingAddress
    MailingAddrID PK
    MailingAddrLine1
    MailingAddrLine2
    MailingAddrCity
    MailingAddrState
    MailingAddrZip
    ClientID FK


    tblEmailAddress
    emailAddr ID
    emailAddr
    ClientID FK


    Code:
      Client ---> MailingAddress
         | 
         +------>EmailAddress
    Good luck.

    NOTE: Just saw Steve's post. His approach should work with your current structures.
    Good point Steve re use the report sorting and grouping. Don't rely on the query.
    Last edited by orange; 03-11-2015 at 07:37 PM. Reason: saw Steve's post

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    For the report, you might be able to use a Union query.
    Try:
    Code:
    SELECT DISTINCT Customers.Customer, Customers.Address , "A" AS X
    FROM Customers
    UNION 
    SELECT DISTINCT Customers.Customer, Customers.Email, "E" AS X
    FROM Customers
    Order By Customers.Customer, X, Customers.Address;
    The "A" AS X and "E" AS X are to be able to sort the addresses first, then the email addresses. Use in the report Sorting and Grouping....

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

Similar Threads

  1. Grouping
    By McArthurGDM in forum Queries
    Replies: 3
    Last Post: 08-11-2014, 03:56 PM
  2. Grouping by certain qty.
    By reldridge in forum Queries
    Replies: 1
    Last Post: 12-03-2012, 03:41 PM
  3. Help with grouping
    By RachelBedi in forum Queries
    Replies: 1
    Last Post: 11-05-2012, 12:55 PM
  4. Grouping
    By EricF in forum Reports
    Replies: 5
    Last Post: 07-18-2011, 03:58 PM
  5. Grouping
    By dref in forum Reports
    Replies: 1
    Last Post: 01-16-2010, 08:30 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