Hi,
I have a field DriverNo in a table called tblStaff.
I have made the property Indexed to be Yes (No Duplicates).
I would like a message to pop up if a user tries to enter a duplicate
DriverNo.
I've never used Message Boxes before.
Thanks
Greg.
Keith Wilby - 09 Feb 2006 12:46 GMT
> Hi,
>
[quoted text clipped - 6 lines]
>
> I've never used Message Boxes before.
You will get a run-time error message for free if a duplicate entry is
attempted.
Regards,
Keith.
www.keithwilby.com
John Spencer - 09 Feb 2006 13:27 GMT
Where (from a form, from a datasheet) and When (upon entry of the data for
Driver No, when the record is saved)?
Assumption:
Entry on a form into a control.
When exiting the control after updating it, you want a message warning the
user that this is a duplicate and cannot be saved.
Private Sub txtDriverNoControlName _AfterUpdate()
IF DCount("*","TblStaff","[Driver no]=" & Chr(34) &
me.txtDriverNoControlName & Chr(34)) > 0 Then
MsgBox "This Driver Number is a duplicate. You may not be able to save
this record",,"Suspected Duplicate"
END IF
End Sub
If Driver No is a number field and not a text field then remove the Chr(34)
from the DCount.
> Hi,
>
[quoted text clipped - 10 lines]
>
> Greg.