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

Duplicate query recordset

I have a list of 160,000 records with these fields:

fname, lname, address, city, state, zip, dob

I need to generate a list with all fields where the first initial of lname
and the dob are equal.

How? I can't seem to get Left() to work in a query. Could I put this in a
VBscript and generate a recordset? What's the easiest way to generate this
list? This seems so simple.

Thanks for your help.
--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
2 2991
The Left function works fine for me, in a Query.

I accomplished what you want with three simple Queries: a Totals Query,
qtotMatching, with the Initial, BirthDate, and a count of Employee ID, with
a criteria on the count of >1, which in SQL view is:

SELECT Count(Employees.EmployeeID) AS CountOfEmployeeID, Left([LastName],1)
AS Initial, Employees.BirthDate
FROM Employees
GROUP BY Left([LastName],1), Employees.BirthDate
HAVING (((Count(Employees.EmployeeID))>1));

another Query, qryEmpWInit that that included all Fields from the Employees
table plus the initial Field, which in SQL view is:

SELECT Employees.EmployeeID, Left([LastName],1) AS Initial,
Employees.LastName, Employees.FirstName, Employees.Title,
Employees.TitleOfCourtesy, Employees.BirthDate, Employees.HireDate,
Employees.Address, Employees.City, Employees.Region, Employees.PostalCode,
Employees.Country, Employees.HomePhone, Employees.Extension,
Employees.Photo, Employees.Notes, Employees.ReportsTo
FROM Employees;

then a third Query, qryShowFields, with those two queries as data sources,
drag and drop join lines from Initial in the qtotMatching to Initial in the
qryEmpWInit, and also from BirthDate in qtotMatching to BirthDate in
qryEmpWInit, displaying all the Fields from qryEmpWInit, except the Initial
Field, which in SQL view is:

SELECT qryEmpWInit.EmployeeID, qryEmpWInit.LastName, qryEmpWInit.FirstName,
qryEmpWInit.Title, qryEmpWInit.TitleOfCourtesy, qryEmpWInit.BirthDate,
qryEmpWInit.HireDate, qryEmpWInit.Address, qryEmpWInit.City,
qryEmpWInit.Region, qryEmpWInit.PostalCode, qryEmpWInit.Country,
qryEmpWInit.HomePhone, qryEmpWInit.Extension, qryEmpWInit.Photo,
qryEmpWInit.Notes, qryEmpWInit.ReportsTo
FROM qtotMatching INNER JOIN qryEmpWInit ON (qtotMatching.BirthDate =
qryEmpWInit.BirthDate) AND (qtotMatching.Initial = qryEmpWInit.Initial);

And, to get useful test data, I copied the BirthDate Field so that both
Employees whose name began with D had the same BirthDate.

If you create a test Databases, link the Employees Table of the sample
Northwind database that comes with Access, copy each of these Queries into
the SQL view of a new Query, save them with the names I used, and run them
to test, you will have a starting point -- use a similar approach with your
own Tables and Fields, of course.

Larry Linson
Microsoft Access MVP

"P B via AccessMonster.com" <fo***@AccessMonster.com> wrote in message
news:53***********@AccessMonster.com...
I have a list of 160,000 records with these fields:

fname, lname, address, city, state, zip, dob

I need to generate a list with all fields where the first initial of lname
and the dob are equal.

How? I can't seem to get Left() to work in a query. Could I put this in
a
VBscript and generate a recordset? What's the easiest way to generate
this
list? This seems so simple.

Thanks for your help.
--
Message posted via http://www.accessmonster.com

Nov 13 '05 #2
In the past I have done this by using an SQL sub query to to the duplicate
matching.

Assuming your data is in a table "tblClient".

First create a query "qClient" to list all of the fields in tblClient:

SELECT tblClient.*
FROM tblClient;

Next build a query with a sub query to count matched records:

SELECT (SELECT Count(tblClient.dob) AS Count FROM tblClient where
(DOB=qclient.dob and left(Iname,1)=left(qclient.Iname,1)) ) AS Count,
qClient.*
FROM qClient;

You may then filter the query output to select duplicate records which
will have a Count>1:

SELECT (SELECT Count(tblClient.dob) AS Count FROM tblClient where
(DOB=qclient.dob and left(Iname,1)=left(qclient.Iname,1)) ) AS Count,
qClient.*
FROM qClient
WHERE ((((SELECT Count(tblClient.dob) AS Count FROM tblClient where
(DOB=qclient.dob and left(Iname,1)=left(qclient.Iname,1)) ))>1));

I hope that this helps.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
1
by: Robert | last post by:
How can I query an existing table and update a field in each record in the table with the occurrence count of each record e.g. update field to 1 (= first record occurrence), update field to 2 for...
3
by: munkis29 | last post by:
Hey all, Hopefully someone here can help me, I've got a problem and not sure how to aproach it. I'm using Access 2003 and have a table with one field: FileID in it there are many values, many of...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
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...
4
by: mcca0081 | last post by:
hi - i'm trying to delete one of the duplicate records based on the most current date. here's the code for my access 2000 db. any help would be appreciated!!! - thank you kindly Sub...
0
by: BSB | last post by:
Hi, I generate a "Find Duplicate" query for one table that will return some records I want to capture those records in my VB code..... This is my code...pls guide me how to proceed.......
5
by: Sheol | last post by:
Hello everyone! Can somebody please help me with this... I have a VB program that inputs Name and Address. I've made a database in MS Access using ADO Control: Table Name: Contacts Fields are:...
1
by: VinArt | last post by:
MS Acc 2003, XP Thank you in advance for any help. I have tables called "Makeup" and "Lines". Each makeup can have multiple lines. Goal is to create a new "makeup" with identical "lines"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.