Results 1 to 5 of 5
  1. #1
    jaxba is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    2

    Use table in other table twice?

    Hi,

    I’m working with a database with two tables: Address Book and Project (this is just an example).

    Address Book:
    Company ID
    Company Name
    Address
    City

    Project:
    Project No.


    Project Name
    Supplier ID
    Customer ID

    Supplier ID and Customer ID should relate to Company ID from Address Book, but I can’t figure out how to relate these fields in order to make it work. I would really like to avoid to have two Address Books (one for suppliers and one for Customers), but what’s the best solution?

    Cheers.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Address Book can be related to both SupplierID and CustomerID fields. Just pull Address Book table into query twice.

    Advise no spaces or special characters/punctuation (underscore is exception) in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    I assume that one company can have many projects, so perhaps this would work for you:
    Remove Supplier ID and Customer ID from table Project and replace them with a new field called CompanyID which should be a data type field, assuming that Company ID in table Address Book is an Auto-Number type field. Create another new field in table Project called CompanyType as a text field. In the sub form that you would use to enter data, use a combo box control bound to the new CompanyType field. The combo box could be set to only offer a choice of Supplier or Customer.

    EDIT:
    Advise no spaces or special characters/punctuation (underscore is exception) in naming convention.
    Excellent advice. IMHO.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    jaxba is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    2
    Quote Originally Posted by June7 View Post
    Address Book can be related to both SupplierID and CustomerID fields. Just pull Address Book table into query twice.
    I’m sorry, but I’m not sure I understand you correct…

    It will work fine if I create the relationships in the query (with two Address Books tables and the Project table), but not if I make the relationship in ‘Relationships’ - is that correct?

    I would assume that I needed a relationship between SupplierID=CompanyID and CustomerID=CompanyID (as a real relationship), but I only have some kind of relationship (join?) defined in the query at the moment…


    Quote Originally Posted by June7 View Post
    Advise no spaces or special characters/punctuation (underscore is exception) in naming convention.
    I fully agree. It's just an example ;-)

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Relationships in relationship builder are not required for db to function but you can set this double relationship by dragging the table into relationship builder twice, just like in query. Established relationships will aid when building queries as well as aid with data integrity, but not mandatory. I often ignore the relationship builder.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-28-2013, 01:59 PM
  2. Replies: 4
    Last Post: 08-30-2012, 07:58 PM
  3. Replies: 8
    Last Post: 03-22-2012, 08:48 AM
  4. Replies: 2
    Last Post: 08-01-2011, 11:35 PM
  5. Replies: 2
    Last Post: 10-27-2009, 07:09 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