no, I do not want duplicated data in my form!!!!!

A

ANGELICA

Hello everyone!
I need to find the way of blocking an specified field from entering exiting
data, even better,stopping duplicated records .I Know that is silly, but I
just can't do it!!! I already tried to set the unique index but it doesn't
work so well since there is not warning showed to current user until record
is about to be saved.

Oh, one more, does anyone know how to customize error messages?

Somebody help me please
 
J

John Vinson

Hello everyone!
I need to find the way of blocking an specified field from entering exiting
data, even better,stopping duplicated records .I Know that is silly, but I
just can't do it!!! I already tried to set the unique index but it doesn't
work so well since there is not warning showed to current user until record
is about to be saved.

Oh, one more, does anyone know how to customize error messages?

Somebody help me please

These are basically two ways of asking the same question... <g>

Try putting code like this in the BeforeUpdate event of the Form
textbox that you don't want duplicated. Adjust the fieldnames to your
own situation of course:

Private Sub txtMyField_BeforeUpdate(Cancel as Integer)
If Not IsNull(DLookUp("[MyField]", "[MyTable]", _
"[MyField] = '" & [txtMyField] & "'") Then
MsgBox "This value has already been entered!", vbOKOnly
Cancel = True
End If
End Sub


John W. Vinson[MVP]
 
Top