473,395 Members | 1,504 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,395 software developers and data experts.

How to check duplicate records

17
Hello,

I need help.

I have a form and I would like to do a check when I enter a data into the field and once I press enter into the field it will check whether is duplicate or not.

currently I have a form with a subform and when I enter the data into the field it does not give me an error till I goto the subform, which is not good.

Please advise how to fix this.

Many Many thanks
Jul 7 '07 #1
3 16713
dima69
181 Expert 100+
Hello,

I need help.

I have a form and I would like to do a check when I enter a data into the field and once I press enter into the field it will check whether is duplicate or not.

currently I have a form with a subform and when I enter the data into the field it does not give me an error till I goto the subform, which is not good.

Please advise how to fix this.

Many Many thanks
Try this (substitue your names). DAO reference required.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtNewData_BeforeUpdate(Cancel As Integer)
  2. Dim rs As Recordset
  3. Set rs = CurrentDb.OpenRecordset("MyDataTable", dbOpenSnapshot)
  4. rs.FindFirst "txtDataField = """ & Me![txtNewData] & """"
  5. If Not rs.NoMatch Then
  6.     Cancel = True
  7.     MsgBox "Duplicate Value"
  8. End If
  9. End Sub
Jul 7 '07 #2
wongray
17
Try this (substitue your names). DAO reference required.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtNewData_BeforeUpdate(Cancel As Integer)
  2. Dim rs As Recordset
  3. Set rs = CurrentDb.OpenRecordset("MyDataTable", dbOpenSnapshot)
  4. rs.FindFirst "txtDataField = """ & Me![txtNewData] & """"
  5. If Not rs.NoMatch Then
  6.     Cancel = True
  7.     MsgBox "Duplicate Value"
  8. End If
  9. End Sub
Thank you it works perfectly
Jul 8 '07 #3
Thank you very much, it works for me also!
Jul 16 '18 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Neil Tompkins | last post by:
Could any one advise what SQL statement I would need to use, to check a table for any duplicate records e.g that contain the same data within a field. Note that I haven't got the field as a unqiue...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
1
by: d9pierce | last post by:
Hi all, I have a company form that I would like to protect against duplication unless checked. Main point being, that I dont want to just be able to add a duplicate company name in a test box...
2
by: Carroll | last post by:
I'm looking for a way in SQL to find duplicate records in a single table, that are the same based on 3 columns, regardless of what is in the other columns in the duplicate records. I would like to...
5
by: Alan Little | last post by:
I have affiliates submitting batches of anywhere from 10 to several hundred orders. Each order in the batch must include an order ID, originated by the affiliate, which must be unique across all...
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: Ranma13 | last post by:
Hello, I have a duplicate record check written in VB for a check in/check out database. Here's the pseudocode, written for the BeforeUpdate property on the form: If DCount(search for records with...
4
by: Thomas Arthur Seidel | last post by:
Hello to all, I have a small or big problem with a customer data base, where during a change of system we might have created duplicate records. This should be easy to find, you might think, but,...
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...
1
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.