Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45

    Table Relationships w/ Related Record error

    This seems like it should work but I keep getting an error. I have the following tables:

    tblVendors
    tblContractors
    tblPOCs

    tblPOCs holds the points of contact for Vendors & Contractors. I want to set up a 1:M relationship with tblVendors -> tblPOCs and tblContractors -> tblPOCs with cascade delete - if I delete a Vendor than I want to delete all of the associated Vendor's POCs (same with Contractors). All works fine if I have just Vendors/POCs or Contractors/POCs, but if I have both Vendors & Contractors with a 1:M with POCs then I get an error stating a related record is required in (e.g.) tblContractors.

    I don't see how this can be a circular relationship; it seems rather straight forward... to me, that is. Perhaps I have my table and/or relationship structure laid out incorrectly?

    Thanks for any help.



    PS - when solved, I get to work a similar issue with addresses, but the relationships will be 1:1.

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    You get the error when and under what conditions? Can you post a screenshot of your relationships? What exactly is the error?

  3. #3
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    Click image for larger version. 

Name:	Relationships.jpg 
Views:	23 
Size:	30.3 KB 
ID:	17177
    Here is a picture of an example relationship. I get this error when I try to add a record to tblPOCs.

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    You still did not say what error you get. Also, Please describe your Schema. That is, your goal with the relationships. Is tblPOCs your primary table and you can have multiple Vendors and multiple Contractors, etc... ?

  5. #5
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    If I try to add a record to tblPOCs with a fkId from tblVendors I get the error: You cannot add or change a record because a related record is required in table 'tblContractors'

    One vendor can have multiple POCs
    One contractor can have multiple POCs
    POCs is NOT the primary table. I might, in the future, have other organizations that have POCs.

    I can write the VBA code to do what I want, but I would rather use the inherent database functions to cascade delete the related POC record when I delete a parent record from tblVendors or tblContractors. However, before I can delete I need to be able to add a record with this setup.

  6. #6
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    The problem is with the Relationships. By design you are saying you have to have a Vendor and a Contractor before you can have a POC
    Fix this and the problem will disappear. We can't see what else is going on with your forms/queries,etc...

  7. #7
    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,849
    How do Contractors and Vendors relate?

  8. #8
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    There is no relationship between Contractors and Vendors. However, they both have POCs. I was just trying to not have a Contractor's POC table and a Vendor's POC table. I was trying to have a single POC table.

  9. #9
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    Why not have 2 separate foreign key columns in tblPOC, one for Vendors and one for Contractors? Then deletes on either Vendors or Contractors will cascade to tblPOC.

  10. #10
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    I have already tried your suggestion. In fact, I have tried every combination I can think of. I still get the same error mentioned above. I looked at the Northwind example to see how they (MS) handled addresses (which would be similar to POCs). Each entity in Northwind has their address within their table. There is no single "addresses" table that can be shared amongst the different entities.

    I'll leave this one open for a while in hopes of a solution but I'm thinking it's not doable.

  11. #11
    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,849
    Can you tell us in a few lines, plain English what are Contractors and Vendors and WHAT exactly is a point of contact POC in your business?
    Also, it isn't that you want to create a 1:M relationship, it is that the data within your business represents a !:M or M:M relationship.

  12. #12
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    Vendors sell me things. Between the salesmen, PMs, contracts people, I may have a half-dozen POCs for each vendor and I need to keep contact info on each.

    Contractors do the work. Between the PM, billing, etc. I may have 3+ POCs for whom I need to keep contact info.

    I was looking to have a single POCs table, but it doesn't look like I can do that. I can see the Pros for multiple tables...

  13. #13
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    So..

    Vendors 1:M POC
    Contractors 1:M POC

    Vendor POC's do not relate to Contractor POC's. Vendors and Contractors do not share POC's.

    If I understood correctly, then yes, you will need to keep them separate. If you want a single POC table, then you would need junction tables from Vendor and Contractor to POC, i.e tblVendor 1:M tblVendor-POC 1:1 tblPOC and tblContractor 1:M tblContractor-POC 1:1 tblPOC.

  14. #14
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    Thank you. I will need to look into this more thoroughly. I shall report my results, but it may take me a while as I now have additional tasks to complete.

  15. #15
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181
    In my opinion (take that for what it's worth!) this seems like it would work with a normal join, but you would lose referential integrity.

    I think you could also have vendors and contractors in one table. Unless you can think of a very specific reason why they would need to be in separate tables. It seems like to me that you are collecting common data on them already, so they could easily be one table called tblOrganizations or something similar.

    Code:
    Org_ID     Org_Name     Org_Type    webAddr     preferredStatus
    --------------------------------------------------------------
    1             Acme           Vendor       acme.com   Yes
    2             Brawndo       Contractor                   No

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 40
    Last Post: 08-20-2013, 11:38 PM
  2. Replies: 7
    Last Post: 07-02-2012, 10:50 PM
  3. Go To Record with related table Primary Key
    By jamiebull21 in forum Forms
    Replies: 3
    Last Post: 02-17-2012, 09:36 AM
  4. Replies: 12
    Last Post: 09-09-2011, 11:14 AM
  5. Foce new record in related table?
    By thekruser in forum Access
    Replies: 1
    Last Post: 11-08-2010, 02:00 PM

Tags for this Thread

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