473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to prevent to enter duplicate record?

MP
I need a code in the Before Update event procedure, which prevents to
enter duplicate record in a form.

I have the main formX, which takes values from the table named tblX and
a subformY, which takes values form the table named tblY. Both forms
are mutually related with a key CustomerID.

I need a code, which makes:
If is field named txtX in formX AND the field named txtY in the
subformY are equal, or entered before, then generate a massage. The
message has to be generated when the field named txtY in the subformY
is already entered.

Thanks for helping me, Mojca

Nov 13 '05 #1
4 2140
MP
Example:

If the first filed named txtX = 789/05 - formX And
If the secon field named txtY = 07.09.2005 - subformY, then generate a
massage "The record you have entered is a duplicate".

Nov 13 '05 #2
You make no sense, sorry but the example you post seems meaningless to
me, anyone else got it?

Are you saying that you want to make it illegal for the data in afield
in a related table to have the same value as a similar named field in
the parent table?

If so you could code this...

private sub block_txtY()

if me.txtY = [forms].[frmX].[txtX] then
msgbox "That value is not allowed", vbokonly
me.txtY = ""
end if

end sub

Nov 13 '05 #3
MP
Unfortunately not working.
Next time when I entered the same data in a form:
in the first field txtX = 789/05 - formX And
in the secon field txtY = 07.09.2005 - subformY, then
generate a massage "The record you have entered is a duplicate".

Nov 13 '05 #4
MP
And SQL for find duplicare record is:
SELECT First(FrmX.TxtX) AS Patient, First(FrmY.TxtY) AS Date,
Count(FrmX.TxtX) AS NumberOFduplicateTxtX, FrmX.TxtX AS FrmX, FrmY.TxtY
AS Dates, Count(FrmY.TxtY) AS NumberOFduplicateTxtY
FROM FrmX INNER JOIN FrmY ON FrmX.ID_Patient = FrmY.ID_Patient
GROUP BY FrmX.TxtX, FrmY.TxtY
HAVING (((Count(FrmX.TxtX))>1) AND ((Count(FrmY.TxtY))>1));

Nov 13 '05 #5

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...
12
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can...
4
by: D. Shane Fowlkes | last post by:
This may be a very simple question but I'm stumped none the less. I have a form where a user provides comments. There's a Grid below this form which displays all comments in the table so far. On...
1
by: dee | last post by:
I can prevent a duplicate ID from being entered, but can't figure out how to go to the record with that already existing ID. Could someone help? Thanks in advance. Private Sub...
2
by: eazyone | last post by:
I can prevent a duplicate ID from being entered, but can't figure out how to go to that specific record. I keep getting an error message on: Me.Bookmark = rsc.Bookmark Its not opening and...
4
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hi, How can I prevent from an ASP.NET page to resend all the data again when the user press the Refresh button or F5 on the browser? Thanks in advanced, Asaf
6
by: teser3 | last post by:
I have my PHP inserting into Oracle 9i. But how do I prevent duplicate record entries? I only have 3 fields in the insert in the action page: CODE <?php $c=OCILogon("scott", "tiger",...
1
by: chicago1985 | last post by:
I have a unique constraint in my Oracle table for 3 fields. If I enter duplicate info on the table using Oracle client I will get an Ora message error ORA-00001 that tells me it is a duplicate entry...
4
by: jbrumbau | last post by:
Hello, I have been successfully using a database I've created for several months to populate an equipment list for a project we've been working on. However, the form has recently stopped working...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.