Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2007
    Posts
    20

    Unanswered: Preventing duplicate entries

    I have a main form with a subform, linked via STUDENTID.

    On the subform, the following happens:

    (1) Teacher selects their name from a drop-down list (TEACHERID)
    (2) Teacher selects subject name from a drop-down list (SUBJECTID)
    (3) Teacher enters comment into memo field (SUBJECTCOMMENT)

    This data is all contained in the table SUBJECTCOMMENTS, with SubjectCommentID (PK), SubjectID (FK), TeacherID (FK), StudentID (FK)

    The problem is, the current set up (and we have absolutely no time to change table or relationship structure as the database needs to be finished by the end of today!) allows teachers to create duplicate combinations of TEACHER ID, SUBJECTID and STUDENTID.

    This should not be allowed to happen; or at the very least, a warning textbox should appear that warns the user and then clears the data from that record.

    Is there a relatively simple way to prevent this at form level?

    Thank you!!

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Your primary key should therefore become

    [ SubjectID (FK), TeacherID (FK), StudentID (FK ]

    If you make the above your combined primary key then the database itself will not allow you to insert duplicates and will warn you as such
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •