473,395 Members | 1,656 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.

Prevent showing duplicate records in a query

Hi everyone!

I (Along with the help of some of you guys!) have managed to get a
query working which takes multiple values (types of organisation) from
a list box.

The query returns a list of contacts (tblContacts.ContactID, LastName
etc. ) who are linked to these particular organisations.

Some of the contacts are linked to more than one organisation and
therefore show up on the list more than once.

What do I need to do so that any of the contacts only display once in
the list. I've tried changing the UniqueRecords and UniqueValues
property settings of the query but it doesn't seem to work.
Thanks
Suffrinmick

Nov 13 '05 #1
4 33630
<su*********@silvercookie.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi everyone!

I (Along with the help of some of you guys!) have managed to get a
query working which takes multiple values (types of organisation) from
a list box.

The query returns a list of contacts (tblContacts.ContactID, LastName
etc. ) who are linked to these particular organisations.

Some of the contacts are linked to more than one organisation and
therefore show up on the list more than once.

What do I need to do so that any of the contacts only display once in
the list. I've tried changing the UniqueRecords and UniqueValues
property settings of the query but it doesn't seem to work.


Unique Values should do it. Of course it only block duplicates consisting
of ALL columns in the output. If you have two rows with the same Names,
but different values in the other columns then you will still see the name
more than once.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
Unique Values returns unique records based on the fields displayed in the
query's output. Unique Records displays unique records based on all fields
in the underlying tables. You may need to use two queries to get what you
want or, perhaps, while linking on the OrganizationID, don't include it or
any of the Organization information in the output of the query (uncheck the
Show box).

Example, this will filter on the date in Table2.Field2, but will only show
Unique Values from the fields selected in Table1. As you can see,
Table2.Field2 isn't listed as an "output" field at the start of the
statement. It is only used in the WHERE clause.

SELECT DISTINCT Table1.Test1, Table1.Test2
FROM Table1 INNER JOIN Table2 ON Table1.Test1 = Table2.Field1
WHERE (((Table2.Field2) Between #1/1/2000# And #12/31/2004#));

--
Wayne Morgan
MS Access MVP
<su*********@silvercookie.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi everyone!

I (Along with the help of some of you guys!) have managed to get a
query working which takes multiple values (types of organisation) from
a list box.

The query returns a list of contacts (tblContacts.ContactID, LastName
etc. ) who are linked to these particular organisations.

Some of the contacts are linked to more than one organisation and
therefore show up on the list more than once.

What do I need to do so that any of the contacts only display once in
the list. I've tried changing the UniqueRecords and UniqueValues
property settings of the query but it doesn't seem to work.
Thanks
Suffrinmick

Nov 13 '05 #3

Wayne Morgan wrote:
Unique Values returns unique records based on the fields displayed in the query's output. Unique Records displays unique records based on all fields in the underlying tables. You may need to use two queries to get what you want or, perhaps, while linking on the OrganizationID, don't include it or any of the Organization information in the output of the query (uncheck the Show box).

Example, this will filter on the date in Table2.Field2, but will only show Unique Values from the fields selected in Table1. As you can see,
Table2.Field2 isn't listed as an "output" field at the start of the
statement. It is only used in the WHERE clause.

SELECT DISTINCT Table1.Test1, Table1.Test2
FROM Table1 INNER JOIN Table2 ON Table1.Test1 = Table2.Field1
WHERE (((Table2.Field2) Between #1/1/2000# And #12/31/2004#));

--
Wayne Morgan
MS Access MVP
<su*********@silvercookie.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi everyone!

I (Along with the help of some of you guys!) have managed to get a
query working which takes multiple values (types of organisation) from a list box.

The query returns a list of contacts (tblContacts.ContactID, LastName etc. ) who are linked to these particular organisations.

Some of the contacts are linked to more than one organisation and
therefore show up on the list more than once.

What do I need to do so that any of the contacts only display once in the list. I've tried changing the UniqueRecords and UniqueValues
property settings of the query but it doesn't seem to work.
Thanks
Suffrinmick


Nov 13 '05 #4
I've managed to figure it out:

Select DISTINCTROW tblContacts.*, tblOrgTypes.OrgType,
tblPositions.Position, tblPositions.Organisation FROM tblOrgTypes INNER
JOIN (tblPositions INNER JOIN tblContacts ON tblPositions.Contact =
tblContacts.ContactID) ON tblOrgTypes.OrgTypeID = tblPositions.OrgType
Where [tblPositions.OrgType] In(" & Criteria & ");
Thanks Wayne and Rick

Suffrinmick

Nov 13 '05 #5

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

Similar topics

1
by: Rado | last post by:
Hi All, This might quite simple process for some but I am finding it really difficult to do. What is required is not a standard Duplicate query but a variation on it. For example I have...
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...
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...
6
by: sara | last post by:
I have a procedure to automate bringing several Excel files into our Access tables, on a daily basis. The problem is that if the user has a problem, and tries to run the import again (maybe 3...
4
by: keithb | last post by:
A page uses query string values to add a record to a database. The record should be added only once; however, if a user activates the url additional times, multiple records are added. Is there some...
2
by: jmarr02s | last post by:
I don't know what I am doing wrong I get duplicate records when I query Here is my SQL query code: SELECT Utilization_T.Facid, Utilization_T.Year, Utilization_T.Beds, Utilization_T.LicBeds,...
11
by: ariel81 | last post by:
i have created a function to input data from four textboxes into a table. how do i prevent duplicate records of the same mth/Yr into the table? editing of the data in the table with reference to the...
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.