[AccessD] Prevent Duplicates

William Hindman wdhindman at bellsouth.net
Thu Apr 22 14:47:30 CDT 2004


Virginia

...if you truly want to prevent duplicates, I'd just create an index on the
table field set to no duplicates allowed and code for an error ...much more
certain to catch dupes, requires less code, and far less processing.

William Hindman
"Always code as if the person who is maintaining or testing your code is
a violent psychopath who knows where you live." William Silverstein


----- Original Message ----- 
From: "Hollis,Virginia" <HollisVJ at pgdp.usec.com>
To: <accessD at databaseadvisors.com>
Sent: Thursday, April 22, 2004 10:02 AM
Subject: [AccessD] Prevent Duplicates


> I need a way to check if a vendor number is a duplicate entry. On the
> AfterUpdate of VenNumber I placed the below code, but it produces an error
> about not finding the Automation Object and gives the entry I made in the
> VenNumber field. VenNumber is a text field - do I have the quotes or
> parenthesis wrong?
>
> Virginia
>
> ************************
>  If Not IsNull(VenNumber) Then
>     If DCount("VenNumber", "tbl_Vendor", "VenNumber = " & [VenNumber]) > 0
> Then
>         MsgBox "You have entered a Vendor Number that already exists"
>         VenNumber.SetFocus
>         VenNumber.Undo
> End If
>     End If
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>





More information about the AccessD mailing list