Connecting Tech Pros Worldwide Help | Site Map

Duplicate Records Warning

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 01:55 AM
Peter
Guest
 
Posts: n/a
Default Duplicate Records Warning

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, 01:55 AM
Allen Browne
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.