Not Getting a Duplicate Primary Key Error

B

BK

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
 
B

Bill

No, I don't have anything like that for that form. I did have a Response =
acDataErrContinue in there, but that's after the event comes up and my
custom MsgBox pops up. I commented it out just to see if it was doing that,
and it still comes up with nothing. I'm trying to trap it in the form's
OnError event. But the thing is I'm not getting any error. Not when I
close the form or try to do a save record anyway. Like I said before, if I
try to go to the next record via the navigation buttons it pops the error.
Very weird. I've not seen this before. Anyone with other ideas?

Thanks,
Bill
 
B

Bill

Just a thought. It's not a primary key that is being violated, but rather a
unique index that is being violated. Does that make a difference at all? I
still don't get the reason why it fires when I click the navigation button
but not when I try to do a save record operation through VBA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top