A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Do I need a subquery?



 
 
Thread Tools Display Modes
  #1  
Old February 19th, 2010, 04:03 AM posted to microsoft.public.access.queries
BARRY
external usenet poster
 
Posts: 383
Default Do I need a subquery?

Hi:
I am having problems creating a query to show cars with WorkOrders. The
tables involved are Customers (CustomerID as PK), CustomerCars (CardID as PK,
CustomerID as FK) and WorkOrders (WorkOrderID as PK, CustomerID as FK, CarID
as FK). I would like to have a query as the recordsource for a listbox that
shows the WorkOrderID, CustomerName, CarYear, CarMake and CarModel. My
problem is that I keep getting all of the customers' cars with the same
WorkOrderID. ie If I am the customer and I have 5 cars listed in CustomerCars
they all show in the query and I only want the one associated with the
WorkOrderID. Any help is greatly appreciated. I hope that I have explained
the probelm well enough. Please let me know if there are additional
questions.
Thanks,
Barry
  #2  
Old February 19th, 2010, 05:49 AM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Do I need a subquery?

Try this --
SELECT WorkOrderID, CustomerName, CarYear, CarMake and CarModel
FROM (WorkOrders INNER JOIN Customers ON WorkOrders.CustomerID =
Customers.CustomerID) INNER JOIN CustomerCars ON WorkOrders.CarID =
CustomerCars.CarID
WHERE WorkOrderID = [Forms]![YourFormName]![Listbox];

--
Build a little, test a little.


"Barry" wrote:

Hi:
I am having problems creating a query to show cars with WorkOrders. The
tables involved are Customers (CustomerID as PK), CustomerCars (CardID as PK,
CustomerID as FK) and WorkOrders (WorkOrderID as PK, CustomerID as FK, CarID
as FK). I would like to have a query as the recordsource for a listbox that
shows the WorkOrderID, CustomerName, CarYear, CarMake and CarModel. My
problem is that I keep getting all of the customers' cars with the same
WorkOrderID. ie If I am the customer and I have 5 cars listed in CustomerCars
they all show in the query and I only want the one associated with the
WorkOrderID. Any help is greatly appreciated. I hope that I have explained
the probelm well enough. Please let me know if there are additional
questions.
Thanks,
Barry

  #3  
Old February 19th, 2010, 06:47 AM posted to microsoft.public.access.queries
BARRY
external usenet poster
 
Posts: 383
Default Do I need a subquery?

Karl:
Thanks for the reply. It is working for my WorkOrders table however, it is
not working on my Estimates table. I will need to check that table and see
if I have some sort of corruption going on there. Again, thanks for your
help.
Sincerely,
Barry

"KARL DEWEY" wrote:

Try this --
SELECT WorkOrderID, CustomerName, CarYear, CarMake and CarModel
FROM (WorkOrders INNER JOIN Customers ON WorkOrders.CustomerID =
Customers.CustomerID) INNER JOIN CustomerCars ON WorkOrders.CarID =
CustomerCars.CarID
WHERE WorkOrderID = [Forms]![YourFormName]![Listbox];

--
Build a little, test a little.


"Barry" wrote:

Hi:
I am having problems creating a query to show cars with WorkOrders. The
tables involved are Customers (CustomerID as PK), CustomerCars (CardID as PK,
CustomerID as FK) and WorkOrders (WorkOrderID as PK, CustomerID as FK, CarID
as FK). I would like to have a query as the recordsource for a listbox that
shows the WorkOrderID, CustomerName, CarYear, CarMake and CarModel. My
problem is that I keep getting all of the customers' cars with the same
WorkOrderID. ie If I am the customer and I have 5 cars listed in CustomerCars
they all show in the query and I only want the one associated with the
WorkOrderID. Any help is greatly appreciated. I hope that I have explained
the probelm well enough. Please let me know if there are additional
questions.
Thanks,
Barry

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.