Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009

    Unanswered: Key Violation Export to Table

    I am working with an append query for a school that sometimes has duplicates because students leave and come back. Currently if there is a key violation I have to stop the query, export the primary key to Excel and compare against all the records that way. This is so that I can find out which records are the same so that I can check other tables to see if they are up to date. IE if they have taken all the standardized tests which is in another table, because there are times that the student is in the main student table but not in the test table.

    Is there any way that I can create a table with the primary keys that match in the main student table? I want it to add the unique records to the student table then add the records that are already in the student table to a "not unique" table. If I can do this I can manipulate the seven append queries into one. I'm thinking that I need some sort of an IF statement like IF tbl_transfered.EMIS_ID = tbl_student_record.EMIS_ID append to tbl_not_unique ELSE append to tbl_student_record. EMIS_ID is the primary key.


  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    yes you can do what you want, however I suspect the reason for your problems is suspect table design. if pupils are expected to leave and return then your physical desing must cater for that.

    at the very least you need to revise your indexing/primary key strategy, at the very worst you may need toredesign tables, adding new columns or tables as required
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jul 2009
    Pupils are not expected to leave and come back, but sometimes it happens for one reason or another which is why the tables are set up this way. I didn't create the original database but took it over.

    How would the IF statement work? Can I use IIF(tbl_transfered.EMIS_ID = tbl_student_record.EMIS_ID, INSERT INTO tbl_not_unique, INSERT INTO tbl_student_record)?

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