[AccessD] No Duplicates

Robin robin at musicalmemories.co.uk
Tue Aug 7 12:21:45 CDT 2007


Hi Virginia
Try (for a string value)

 If DCount("ContainerNo", "tbl_Containers", "ContainerNo = '" &
[ContainerNo])& "'"

RGds
Robin

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hollis,
Virginia
Sent: 07 August 2007 18:25
To: accessD at databaseadvisors.com
Subject: [AccessD] No Duplicates


I am trying to check for duplicates when a user enters data in the
primary key. I don't want them to be able to enter the data in the field
at all. The ContainerNo is a txt field. I think I am missing a quote or
is this wrong all together?

 

Virginia

*********

Private Sub ContainerNo_AfterUpdate()

 If Not IsNull(ContainerNo) Then

    If DCount("ContainerNo", "tbl_Containers", "ContainerNo = " &
[ContainerNo]) > 0 Then

        MsgBox "You have entered a Container that already exists"

        ContainerNo.SetFocus

        ContainerNo.Undo

    End If

End If

End Sub

-- 
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