By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

Duplicate Records Warning

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


Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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:10*************@corp.supernews.com...
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".

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.