Results 1 to 6 of 6
  1. #1
    Jaq is offline Novice
    Windows 8 Access 2003
    Join Date
    May 2016
    Posts
    7

    Querying A Table With Multiple Entries in One Field

    Hi,



    I'm very new to Access so forgive me if this is a really simple question!

    I'm trying to write a query that produces a database of customers and their contact details. The customer reference, name and address is held in one table and the contact details are held in another. The problem I am encountering is that the contact details are stored in one field called CONVAL and could either be email addresses, telephone numbers or both.

    The format of the query I have designed is below (sorry I'm not allowed by work to show the database in any way):

    Click image for larger version. 

Name:	Query Example.PNG 
Views:	15 
Size:	4.0 KB 
ID:	24560

    And it returns the following output:

    Click image for larger version. 

Name:	Output Example.PNG 
Views:	14 
Size:	3.9 KB 
ID:	24561

    Is there a way to produce the output so that email address is one column and telephone number is another?

    Thank you.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    your conval table needs an additional column - called say conType. This would contain a value to indicated type - say 1=telephone, 2=email, 3=skype etc.

    then you query would be

    Telephone: iif(conType=1,conval,"")

    Email: iif(conType=2,conval,"")

    Or you could use a crosstab query

  3. #3
    Jaq is offline Novice
    Windows 8 Access 2003
    Join Date
    May 2016
    Posts
    7
    Hi Ajax,

    Thanks for your reply!

    I've added a new field into the query and it's now as below:

    Click image for larger version. 

Name:	Revised Query.PNG 
Views:	12 
Size:	5.7 KB 
ID:	24562

    And the output looks like this:

    Click image for larger version. 

Name:	Revised Output Example.PNG 
Views:	11 
Size:	4.6 KB 
ID:	24563

    The information is now in the correct columns but shows as 2 separate rows for each customer. Is there a way to produce the information on 1 row rather than 2 so that their email address and phone number is shown on the same line?

    Thanks and sorry to ask such basic questions!

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Or you could reorganize the contact table

    CustRef
    ContactFName
    ContactLName
    ContactAddrLine1
    ContactAddrLine2
    ContactAddrCity
    ContactAddrStateProv
    ContactPhone
    ContactEmail
    ContactSkype
    ContactFaceBook
    ....

    1 fact 1 field

    Be cautious with this sort of thing
    ..a way to produce the information on 1 row rather than 2 so that their email address and phone number is shown on the same line?...
    data storage/structure is one thing
    data presentation is another

  5. #5
    Jaq is offline Novice
    Windows 8 Access 2003
    Join Date
    May 2016
    Posts
    7
    Hiya,

    Because the data feeds into our main live system I am unable to update the table layout - they are hard coded by our software supplier. Sadly I can only query the information contained in the tables themselves.

    Jaq

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    Is there a way to produce the information on 1 row rather than 2 so that their email address and phone number is shown on the same line?
    you can use a crosstab query based on table2 and join that to table 1 in place of table2

    for the crosstab (assuming cusRef is the name of your linking field in table2)

    cusRef - row heading
    conMethod - column heading - note you might want to use a formula instead - iif(conMethod=1,"Phone","Email")
    conVal - value (use first)


    then link this query to table1 instead of table2

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

Similar Threads

  1. Replies: 2
    Last Post: 03-18-2015, 07:39 AM
  2. Multiple entries to one record without adding new field?
    By Yamilet in forum Database Design
    Replies: 7
    Last Post: 06-01-2013, 04:22 PM
  3. Adding Multiple Entries To 1 Table
    By sivega in forum Forms
    Replies: 2
    Last Post: 05-29-2013, 12:04 PM
  4. Field with multiple entries....?
    By norlo in forum Database Design
    Replies: 1
    Last Post: 05-12-2011, 12:04 PM
  5. merge multiple entries in table
    By rajsa in forum Database Design
    Replies: 1
    Last Post: 07-02-2010, 07:16 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