By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

Getting a Duplicate Primary Key Error

P: n/a
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.RunCommand 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.RunCommand acCmdGoToRecordNext just to try
and mimic that process, but still nothing. Does anyone know what I could do
to possibly pop this error?

TIA,
Bill
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.