[AccessD] No Duplicates

McGillivray, Don [IT] Donald.A.McGillivray at sprint.com
Tue Aug 7 12:45:16 CDT 2007


Nope.

Should be:

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

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Robin 
Sent: Tuesday, August 07, 2007 10:22 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] No Duplicates

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

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