Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2005

Tip: Looking for answers? Try searching our database.

Help needed with ONLY VBA code or query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Moore - 28 Dec 2005 19:17 GMT
I have a table of customers who may have purchased numerous types of
products. Finding out who purchased what is easy. However, what I need
to determine is which customer has purchased ONLY one or two
particular products and NOTHING else.

There is a customers table where each customer has a unique ID, a
product table where each product has a unique ID, and a sales table
that has records for each customer and the products they purchased. I
would like to find out which customers purchased only product1 and/or
product2 and no other product types in the product line.

I cannot get my mind around how to either write a VBA code and/or a
query to determine which customer may have purchased only one product
regardless of how many of the one item they purchased.

Any and all help is greatly appreciated.

TC
Brian Wilson - 28 Dec 2005 19:38 GMT
>I have a table of customers who may have purchased numerous types of
> products. Finding out who purchased what is easy. However, what I need
[quoted text clipped - 14 lines]
>
> TC

You could do it using subqueries.  We don't know table and field names, but
the query should be something like:

SELECT tblCustomer.* FROM tblCustomer WHERE
tblCustomer.CusID IN (SELECT tblSales.CusID FROM tblSales WHERE
tblSales.ProdID IN (5,9))
AND
tblCustomer.CusID NOT IN (SELECT tblSales.CusID FROM tblSales WHERE
tblSales.ProdID NOT IN (5,9))

... this assumes that 5 and 9 represent the ID's of the 2 products you are
interested in.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.