Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Checking for duplicates when clicking out of a field


Message #1 by "Michelle Madden" <michellem@a...> on Wed, 9 May 2001 21:21:32
Hi,



Can anyone help?



I have an Access Form and I an entering client information.  The first 

field to enter is an unique code, currently it only checks for duplicates 

when I save the record, I would like it to check the table for a duplicate 

when I exit the field.



Thanks



Michelle



Message #2 by "Levine, Lloyd" <LEVINLL@m...> on Wed, 9 May 2001 13:38:41 -0700
You need to add some code to the AfterUpdate method of that field.



-----Original Message-----

From: Michelle Madden [mailto:michellem@a...]

Sent: Wednesday, May 09, 2001 5:22 PM

To: Access

Subject: [access] Checking for duplicates when clicking out of a field





Hi,



Can anyone help?



I have an Access Form and I an entering client information.  The first 

field to enter is an unique code, currently it only checks for duplicates 

when I save the record, I would like it to check the table for a duplicate 

when I exit the field.



Thanks



Michelle



Message #3 by "Pardee, Roy E" <roy.e.pardee@l...> on Wed, 09 May 2001 13:43:20 -0700
Will the OnLostFocus event of your control suit?  You should be able to call

whatever code you're using to check dupes from that event to get the

behavior you want.



HTH,



-Roy



-----Original Message-----

From: Michelle Madden [mailto:michellem@a...]

Sent: Wednesday, May 09, 2001 2:21 PM

To: Access

Subject: [access] Checking for duplicates when clicking out of a field





Hi,



Can anyone help?



I have an Access Form and I an entering client information.  The first 

field to enter is an unique code, currently it only checks for duplicates 

when I save the record, I would like it to check the table for a duplicate 

when I exit the field.



Thanks



Michelle

Message #4 by Brian Skelton <brian_skelton@o...> on Wed, 9 May 2001 22:24:27 GMT
Hi Michelle



You need to add something like the following to the controls 

before update event:



(This code assumes that the field name that the data is 

coming from is called FieldName and the control is called 

ControlName)



Dim rst As Recordset

Dim strSearch As String



    Set rst = Me.RecordsetClone

    strSearch = "FieldName = '" & Me![ControlName].Value & "'"

    rst.FindFirst strSearch

    

    If Not (rst.NoMatch) Then

        Cancel = True

        Beep   'Put some nice message in here to inform the 

user!

    End If



-BDS


  Return to Index