No duplicate value based on another value

As soon as I insert this code it turns red.
 
The error message that you get, implies that the values of the controls called “Me.Employee_ID” and “Me.Date_Completed” are both Null. However, when you looked at their values after placing a break point they showed the expected values. This seems bizarre. IMHO, things that seem bizarre are often a sign of corruption. If the form has some corruption, you may need to create a new form.
I have attached a db. It has a form called frmBobsTest. Import that form into your own db. It should show all the records from your table called “TBL_EmpTrainDate”. Try to create a duplicate record and then let us know if the code in it works as we would expect.
What date format do you use? dd/mm/yyyy or mm/dd/yyyy
 
Sorry but I didn't get the attached db. I am using mmddyyyy. I wouldn't be surprised if this form is corrupted. It is an old database that has been used hard.
 
It has been a long day and I'm sure it must be late for you. I'll try this and see how it goes. Thanks.
 
Actually it's only 8:35 pm, but I've been up since 4:00 am
 
OK So it's not working because the training number is an autonumber and I'm not able to input the number I need.
 
It let me input the data once with no errors. But I can't try a duplicate.
 
Try to create a new record where just Employee_ID and Date_Completed are duplicates.
 
OK That worked. So I guess there's no hope for my form.
I think your form is corrupt. You could try doing a compact and repair on your db. You could try creating a new blank db and importing every thing into the new db, but My guess is that your existing form will have to be replaced.
Once you have a form that is not corrupt, we can work on the code to catch your duplicates.
 
I appreciate all your help. At this point I'm ready to go in a different direction. I'll let you know if I need anymore help. Thanks to all who tried to help.
 

Users who are viewing this thread

Back
Top Bottom