473,587 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query for duplicates

24 New Member
I have a data-entry application which saves records to an Access db. I need to build in a query to search for duplicate entries before a save is performed. There are 2 fields that would generate a duplicate; UserID and WeekEndingDate. If more than 1 record is found for the same combination I want to have a pop-up message saying that the combo already exists. Thanks for the help!!

p.s. - I am coding in vb.net
Apr 7 '08 #1
2 784
rkeith27
6 New Member
If I understand it correctly...
I didn't try the query but it should be correct, if not it's real close.


SELECT userID,
COUNT(userID) AS userID_NumOccur rences, weekEndingDate,
COUNT(weekEndin gDate) AS weekEndingDate_ NumOccurrences
FROM tableA
GROUP BY userID, weekEndingDate
HAVING ( COUNT(userID) > 1 AND COUNT(weekEndin gDate) > 1)
Apr 7 '08 #2
juster21
24 New Member
If I understand it correctly...
I didn't try the query but it should be correct, if not it's real close.


SELECT userID,
COUNT(userID) AS userID_NumOccur rences, weekEndingDate,
COUNT(weekEndin gDate) AS weekEndingDate_ NumOccurrences
FROM tableA
GROUP BY userID, weekEndingDate
HAVING ( COUNT(userID) > 1 AND COUNT(weekEndin gDate) > 1)
thanks for the help. Any chance you could help translate this into a SQL statement for use in vb code? The ultimate goal is to produce an error message if the count is greater than 1. Thanks again!!
Apr 7 '08 #3

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

Similar topics

3
4597
by: Tom Mitchell | last post by:
All: I'm stumped on a query. How do I find duplicates in a table where one of the duplicates has values is a certain field and the other doesn't. For example, I have the following table: tblItems ItemID ItemLabel
5
3289
by: Lyn | last post by:
This one is difficult to explain, so I will cut it down to the basics. I have a major table 'tblA' which has an autonum field 'ID-A' as primary key (of no significance to users). 'tblA' contains many fields including picture and memo fields. The main user-selectable field is 'NameA'. There is also a crossreference table (let's call it...
3
4807
by: Sim Zacks | last post by:
I am using 8.0 beta 1 on an RH 8 Linux server. I have a union query that I am converting from access (where it worked) and it is returning duplicates. The only difference between the two rows is the Row field, which is returned automatically. and an example of a row that it has returned duplicate. I have verified that the row only shows...
16
4166
by: tyrfboard | last post by:
I've been searching for awhile now on how to remove duplicates from a table within an Access db and have found plenty of articles on finding or deleting duplicates. All I want to do is remove them from within an SQL query - leaving one of the records behind of course. I have a mailing list comprised of a union query that gets records from...
12
2356
by: Tom | last post by:
Hello, I have a database of employee data in access and I am trying to create a form with combo boxes for criteria (ex. gender, office, position, etc.) that let the user select criteria from drop down menus (ex. they may select Male, New York, Manager) and those criteria will be used to run a query (ie Query by Form). I can do this with...
1
2016
by: JC | last post by:
Hello, I am trying to change a select, find duplicates, query into a delete query. I want to get rid of the records in the main table "tblHurnsHistory." I changed the Find Duplicates query to a Delete query. I then received an input box looking for criteria that states," Enter parameter value qryHurnsHistory.Grads_creditsEarned
16
3482
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate...
0
1296
by: csin | last post by:
I have an Access DB backend for the application I am running, I want to use the built in ability in Access to remove duplicate entries... Say I have table1 with fields field1 field2 and field3, none of the fields are indexed without duplicates for a reason... The way I remove duplicates is to do an append query into an identical table that...
4
7594
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to an excel spreadsheet. There are two tables. One is a list of general contacts, and the other is a list of clubs. The clubs contain members who...
11
4080
beacon
by: beacon | last post by:
Hi everybody, I created a database that links one table from an ODBC data source. I saved my password and UID to the data source so neither myself nor anyone else would have to login each time (that's just bonus background info). I take this table, which is read-only, and run an APPEND query that adds new items from the table into another...
0
7920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
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 we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.