Hi there,
I have a form for data entry, there is a field called "ENCON" that is basically the number of an incident, and is also my primary key. Is there a way to prevent duplicate entries? If I fill out the whole form with a duplicate ENCON # and try to add it, I get a run time error that explains that doing this would result in a duplicate primary key entry. This error would be a bit scary to my users.
Is there a way that I can prevent a duplicate ENCON number as soon as that field is filled? (It's the first field on the form). This way the user would know right away that the incident has already been entered without going thru the tedium of filling out the entire form.
I have tried this:
But it doesn't seem to do anything.
Am I on the right track? Or way off?
-Thanks in advance, Z
I have a form for data entry, there is a field called "ENCON" that is basically the number of an incident, and is also my primary key. Is there a way to prevent duplicate entries? If I fill out the whole form with a duplicate ENCON # and try to add it, I get a run time error that explains that doing this would result in a duplicate primary key entry. This error would be a bit scary to my users.
Is there a way that I can prevent a duplicate ENCON number as soon as that field is filled? (It's the first field on the form). This way the user would know right away that the incident has already been entered without going thru the tedium of filling out the entire form.
I have tried this:
Code:
Private Sub cboENCON_BeforeUpdate(Cancel As Integer)
If DCount("[ENCON]", "Risk_Data") > 0 Then
Me.Undo
MsgBox "ENCON Already exists in database"
End If
End Sub
But it doesn't seem to do anything.
Am I on the right track? Or way off?
-Thanks in advance, Z