Getting a Duplicate Primary Key Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill

    Getting a Duplicate Primary Key Error

    I have a db that tracks students and classes. On my main form I have
    student info. I then have a button on the main form that pops up another
    form that allows someone to add that student to a class. It automatically
    populates the student ID in the proper field and all the person has to do is
    select the class. On this enrollment form I have a "Save and Close" button
    that saves the record (DoCmd.RunComma nd acCmdSaveRecord ) and closes the form
    which brings you back to the main form. The problem comes up when someone
    tries to enter a duplicate record, meaning the same combination of student
    ID and Class ID. If they do this and press the "Save and Close" button,
    nothing happens. Not even an error which I can trap, which I was hoping to
    do. If I add back the Navigation buttons (which I want to keep off in the
    permanent version), and click the next record button the error comes up. I
    then changed the code to DoCmd.RunComman d acCmdGoToRecord Next just to try
    and mimic that process, but still nothing. Does anyone know what I could do
    to possibly pop this error?

    TIA,
    Bill


Working...