I am not Able to delete certain record due to key violation.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pooja raval
    New Member
    • Sep 2010
    • 1

    #1

    I am not Able to delete certain record due to key violation.

    Please help me out to solve my issue. I am Using MS Access I want to delete record form main table where checkbox is unchecked. but i am getting a prompt that you can not delete certain rows due to key violation. This is because the other tables are related with Main "Info" table.
    But i dont know hoe to deal with it. Nad whet is teh other solution to delete records from a table. All the related data from other related tables should be deleetd as well.
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Hi and welcome to bytes
    You dont write which access version your using, however, In AC2000,2002,200 3 you will find in your toolbar a button called relations. (Don't know where it is in 2007). In here you can see and edit the relations between tables, and their primary/foreign keys. If you can't find the relations button, search for it in help.

    Locate the table you want to delete records from in the relations view, and note which tables it is related to.
    Now you know which tables you need to delete records from as well. The error msg you get is telling you that there are related records in these related tables, that if you delete the record from the primary table, these related records will be "orphans".

    Now if you (double) click the link between the tables, you can modify the link properties. Selecting "Cascade delete related records" will make access delete all related records when you delete from the primary table.

    Id also suggest you do quick read up on "relational databases" (just google it).

    Comment

    Working...