Connecting Tech Pros Worldwide Help | Site Map

Duplicate Records Warning

  #1  
Old November 13th, 2005, 02:55 AM
Peter
Guest
 
Posts: n/a
My database has a text field "Registration" ~ it is the only Primary Key and
no duplicates are possible. After you have entered all the fields for a new
record you often find out that it is a duplicate when you try to save it.
Has anyone got a code I can copy and use on the data entry form to produce a
message box to warn that you are beginning to create a duplicate record.
Maybe "After Update" on the "Registration Field".

Thanks




  #2  
Old November 13th, 2005, 02:55 AM
Allen Browne
Guest
 
Posts: n/a

re: Duplicate Records Warning


Just DLookup() the table to see if the value is there.

Private Sub Registration_AfterUpdate()
Dim strWhere As String

With Me.Registration
If .Value = .OldValue Then
'do nothing
Else
strWhere = "Registration = """ & .Value & """"
If Not IsNull(DLookup("Registration", "MyTable", strWhere)) Then
MsgBox "Dupe!"
End If
End If
End With
End Sub

If you need more help with DLookup() see:
http://members.iinet.net.au/~allenbrowne/casu-07.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter" <peter@_nospam_exeter23.freeserve.co.uk> wrote in message
news:10igsru22jilaad@corp.supernews.com...[color=blue]
> My database has a text field "Registration" ~ it is the only Primary Key
> and
> no duplicates are possible. After you have entered all the fields for a
> new
> record you often find out that it is a duplicate when you try to save it.
> Has anyone got a code I can copy and use on the data entry form to produce
> a
> message box to warn that you are beginning to create a duplicate record.
> Maybe "After Update" on the "Registration Field".[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Just a warning on duplicate records jjstevens answers 9 February 15th, 2007 05:51 PM
Code for Duplicate Records Warning Peter answers 6 November 13th, 2005 07:35 AM
counting records in a recordset mgm answers 8 July 21st, 2005 08:44 AM
Easiest way of combining multiple fields from different records into one record? Steve answers 5 July 20th, 2005 05:12 AM