473,474 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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


Nov 13 '05 #1
1 4872
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
8
by: Ray | last post by:
I have a data input form and need to automatically duplicate the existing record as a new record by clicking a button. The main purpose to duplicate the record is that the new record is very...
6
by: Peter | last post by:
Can anyone advise me what is wrong with this code? I want it to tell me if I am entering a duplicate record. However, I always get the "Dupe" error message, whether I have entered a duplicate or...
2
by: news | last post by:
I just upgraded to PHP 4.4.2 on my Slackware 10.2 system. And Apache/mySQL/PHP all work great through a browser. No errors. But when I try to run a PHP script through the command line, which I...
0
by: Johan P | last post by:
Having just compiled DBG 2.15.1 and trying to use it with PHP (cli) give some some problem. Verions: DBG 2.15.1 PHP 4.4.4 (cli) It works fine compiled with the Apache module but when I try...
4
by: afr0ninja | last post by:
Hello! I'm still rather new to using code in access. I've come across a problem that I'm having difficulty troubleshooting. Any assistance would be greatly appreciated! I've set up a form...
9
by: jjstevens | last post by:
I am trying to set up a message box warning (or open to some sort of other warning) when a duplicate record is entered. I do want to allow duplicate records but I am looking to warn when it does...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
2
by: nomvula | last post by:
hi guys i need some help to duplicate records on my form datasheet: here's the example of my form results: ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual UJ...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.