locked
foreign key end of a relationship objectstateentry RRS feed

  • Question

  • How can I know which end comes from the table containing the foreign key relationship.

    EG a customergroup contains several customers. So to the customer table has a foreign key to the customergroup table.

    If I change the customergroup for a customer, i will have a relationship entry for which i want to find the customer in a generic way, because customer holds the foreign key and customer is the table which will eventualy be updated.

    I want to retrive the customer in order to validate it, e.g. is the customergroup allowed for this customer

    kind regards

    voilbak

    Tuesday, March 8, 2011 8:35 PM

Answers

  • Hello voilbak,

     

    Welcome to the MSDN Forum and thanks for posting here.

    According to your description, I think what you would like to know is how to edit records in related tables and maybe the keypoint is Cascade Updates. AmI right?

    If so, for relationships in which referential integrity is enforced, you can specify whether you want Microsoft Access to automatically cascade update and cascade delete related records. If you set these options, delete and update operations that would normally be prevented by referential integrity rules are allowed. When you delete records or change primary key values in a primary table, Microsoft Access makes necessary changes to related tables to preserve referential integrity.

    If you click the Cascade Update Related Fields check box when you are defining a relationship, any time you change the primary key of a record in the primary table, Microsoft Access automatically updates the primary key to the new value in all related records. For example, if you change a customer's ID in the Customers table, the CustomerID field in the Orders table is automatically updated for every one of that customer's orders so that the relationship is not broken. Microsoft Access cascades updates without displaying any message.

    NOTE: If the primary key in the primary table is an AutoNumber field, setting the Cascade Update Related Fields check box will have no effect, because you cannot change the value in an AutoNumber field.

     For more information about relationships, click the following article numbers to view the articles in the Microsoft Knowledge Base:

    304466  (http://support.microsoft.com/kb/304466/ ) Defining relationships between tables in a Microsoft Access database
    304469  (http://support.microsoft.com/kb/304469/ ) How to view and edit relationships in a Microsoft Access Database 
    I hope this can help you. Please feel free to tell me if I misunderstood you.
    Have a ncie day,

    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Jackie-Sun Monday, March 14, 2011 3:14 AM
    • Marked as answer by Jackie-Sun Tuesday, March 15, 2011 3:33 AM
    Thursday, March 10, 2011 7:30 AM