Results 1 to 10 of 10
  1. #1
    Subhunter is offline Novice
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    New Hampshire
    Posts
    8

    Simple query help

    For the life of me I cannot get my query correct to pull the data I need.



    Please see attachment.

    Here's the scenario. We have 1 product, in turn has many parts, those parts have several distributors who supply those parts. We need to send RFQ's to those suppliers who handle the parts. I need to pull the Supplier listed for the ProductName and list all PartNumbers that Supplier can supply.

    i.e. Product ThingAMajigger has 5 parts.

    1st Report

    TTI Inc.
    addy, etc


    UnitsOnOrder PartNumber Description
    100 ABC
    50 DEF



    2nd Report

    Company YYZ
    addy

    UnitsOnOrder PartNumber
    100 ABC
    50 DEF
    25 MNO



    3rd Report

    Company BVD
    addy

    UnitsOnOrder PartNumber
    300 UVW
    250 XYZ

    Any suggestions would be very helpful. I just cannot seem to get my brain in gear this week.

    Thanks in advance.

    Jeff

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Hope this gets you started:

    Code:
    SELECT Products.ProductName, Suppliers.CompanyName, Parts.PartNumber
    FROM Suppliers INNER JOIN (Products INNER JOIN (Parts INNER JOIN PartsDetails ON Parts.PartID = PartsDetails.PartID) ON Products.ProductID = Parts.ProductID) ON Suppliers.SupplierID = PartsDetails.SupplierID
    GROUP BY Products.ProductName, Suppliers.CompanyName, Parts.PartNumber;
    Cheers,

  3. #3
    Subhunter is offline Novice
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    New Hampshire
    Posts
    8
    Thank you for your input but that does not help me right now. I am just getting back in to doing this type of programming and I am a little more rusty than I thought. Any way you could show me the design view of that code? I really appreciate the help.

    Jeff

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Hi Subhunter,
    did you mean that you have only one table for all information including supplier,procduct and parts?

  5. #5
    Subhunter is offline Novice
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    New Hampshire
    Posts
    8
    The attachment has a picture of the relationships between the four tables. For one product I need to print out the RFQ's for each of the parts associated with that product. For the life of me I cannot get my brain in gear to figure it out. Thanks for the help.

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you follow these step to create a query with ConnextionLost's code:
    1 Create query in design view, close the "select table" pop up window
    2 from the menu, select View->SQL view
    3 paste Connextionlost's code
    4 save the query

  7. #7
    Subhunter is offline Novice
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    New Hampshire
    Posts
    8
    Did that but I am getting an error message.

    SELECT Products.ProductName, Suppliers.CompanyName, Parts.PartNumber
    FROM Suppliers INNER JOIN (Products INNER JOIN (Parts INNER JOIN Parts Details ON Parts.PartsID = Parts Details.PartsID) ON Products.ProductID = Parts.ProductID) ON Suppliers.SupplierID = Parts Details.SupplierID
    GROUP BY Products.ProductName, Suppliers.CompanyName, Parts.PartNumber;

    Error states: Sytax error (missing operator) in query expression 'Parts.PartsID = Parts Details.PartsID'.

    Thanks,

    Jeff

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you need [] around all [part details]:
    SELECT Products.ProductName, Suppliers.CompanyName, Parts.PartNumber
    FROM Suppliers INNER JOIN (Products INNER JOIN (Parts INNER JOIN [Parts Details] ON Parts.PartsID = [Parts Details].PartsID) ON Products.ProductID = Parts.ProductID) ON Suppliers.SupplierID = [Parts Details].SupplierID
    GROUP BY Products.ProductName, Suppliers.CompanyName, Parts.PartNumber;

  9. #9
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Additionally, you appear to have different spelling for your [PartsID] key.

    In your [Parts] table, it is [PartsID]; but in your [Parts Details] table, it is [PartID].

    In my previous example, I removed the "s".

  10. #10
    Subhunter is offline Novice
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    New Hampshire
    Posts
    8
    LOL, thx. I did catch that and fixed my tables accordingly so everything matches up and the code I sent back was the corrected copy.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. need help with this simple query
    By dada in forum Programming
    Replies: 3
    Last Post: 08-20-2010, 07:08 AM
  2. simple query
    By taylorosso in forum Queries
    Replies: 1
    Last Post: 10-06-2009, 04:26 AM
  3. Need Help with a very simple query
    By bikerguy06 in forum Queries
    Replies: 3
    Last Post: 06-08-2009, 08:43 PM
  4. Help with a simple query
    By JohnnyO in forum Queries
    Replies: 1
    Last Post: 02-11-2009, 09:43 PM
  5. Should be simple Query Question
    By brj1 in forum Queries
    Replies: 2
    Last Post: 03-04-2006, 01:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums