Results 1 to 6 of 6
  1. #1
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28

    Error when deleting a record

    I have a form "Test_Form_To_Delete" with textbox CustomerID and a button "Delete Record"

    When i select the last record (4, by pressing the next button in record toolbar below the form) and entered "0102864" and When "Delete Record" is pressed I'm getting the following error message "The changes requested for the table are not successful because they would create duplicate values...".

    What i'm expecting is to delete the records present in Customers and Items table with matching customerID "0102864". (Enabled cascade delete in table relationship). Please find the attached database.


    My intuition is that it is trying to create the record instead of looking up for the matching entry. Can any one let me know on how to handle this case.

  2. #2
    thhui is offline Competent Performer
    Windows XP Access 2002 (version 10.0)
    Join Date
    Feb 2009
    Posts
    235
    Could you convert your access2007 file to access 2000 or 2002 format firstly?
    Last edited by thhui; 06-12-2009 at 05:42 AM.

  3. #3
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28

    Uploaded 2002 db format file

    Quote Originally Posted by thhui View Post
    Could you convert your access2007 file to access 2000 or 2002 format firstly?
    Please find the attached DB for 2002 format.

  4. #4
    thhui is offline Competent Performer
    Windows XP Access 2002 (version 10.0)
    Join Date
    Feb 2009
    Posts
    235
    In the bound form just in your case,
    if you want to choose record to delete,
    you must go to the record firstly.

    You cannot just type the customerID in the form and expect it going to the specified record.

    If you do this in the new record just as what you describe,
    you are indeed creating a new record (cause you go to the last one and insert a new one) but with the same customerID.

    This is prohibited as the customerID could not be duplicated by the setting in the table structure.

    In your case, you should instead search the required record and go to it firstly.
    Just put a combo box in the form to have its control source to select the customerID from the customer table.
    then put a button on nearby side and setup a macro or vba code to
    let the form goto the specified customerID record you select.

    Then you can delete the record accordingly.

    I recommend you to study the basic form operation of addition, deletion, searching record in some elementary access book.
    Last edited by thhui; 06-14-2009 at 12:50 AM.

  5. #5
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    Thanks for your reply. I have already figured out that record gets deleted only when you go to the specified record and delete button is clicked.

    But what m looking for is, is there any other way to do for "just enter customerID and delete the record". The example which i have shown is part of my application.

    In my original form, when the form is opened user fills the details in the fields of the form and selects delete. The user doesnot know where exactly the specified record is (..and its obvious) in order to go to that specified record and delete it. Also there wont be any records available in the form (to click on 'next record" below the fom), even though the form is bound to a table.

    Hope you understand what i want to accomplish with the example above. I'm thinking to write a query to do this. Can you suggest on how to go about with this.

  6. #6
    thhui is offline Competent Performer
    Windows XP Access 2002 (version 10.0)
    Join Date
    Feb 2009
    Posts
    235
    Don't use bound form.

    Just put a combo box in the form to have its control source to select the customerID from the customer table.
    then put a button on nearby side and setup a macro or vba code to
    delete the record accordingly.

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

Similar Threads

  1. Find Record button error
    By Zedlexx in forum Forms
    Replies: 0
    Last Post: 03-11-2009, 09:26 AM
  2. Error "Record is Deleted"
    By koper in forum Access
    Replies: 8
    Last Post: 03-10-2009, 10:20 AM
  3. Problem Deleting Records with ADO
    By bdicasa in forum Programming
    Replies: 0
    Last Post: 08-21-2008, 09:27 AM
  4. Deleting Record Contents, not complete record...
    By Charles Waters in forum Access
    Replies: 2
    Last Post: 06-24-2008, 12:00 PM
  5. Deleting Spaces
    By grgerhard in forum Import/Export Data
    Replies: 2
    Last Post: 04-30-2006, 06:42 PM

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