Results 1 to 2 of 2
  1. #1
    DarrenReeder is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    9

    Update Query that uses fields from other tables?

    Hello,



    This is my situation.. I have got two table "tbl_Ordered-Products" and "tbl_Orders"..

    The tbl_Orders just stores the order information, then Ordered Products has a relationship with the orders and stores what products are in the order..

    Here is a screenshot of the relationship between tbl_Order and tbl_Ordered-products..



    So, basicly i need to get all of the "Total" fields from tbl_Ordered-Products and add them all together for the Total_Cost field in tbl_Orders.... I know this is done through a query although im just not sure how i would do this...

    -thanks for help on this!

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    First and foremost, you should not be storing the totals in either the tbl_Ordered-Products or in tbl_Orders. The totals should be calculated on the fly when you need them; you would use an aggregate query to determine the totals.

    The following illustrates the basic structures of the queries you need; you will have to substitute your own field/table names (I tried to use your actual ones as much as possible from your post)

    query name: qryOrderDetail
    Select OrderIDField, ProductID, Price, quantity, Price*quantity as LineTotal
    From tbl_Ordered-Products

    query name: qryOrderTotal

    Select OrderIDfield, Sum(LineTotal) as OrderTotal
    From qryOrderDetail
    Group by OrderIDfield

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

Similar Threads

  1. Cant update fields when using a query
    By JohnBoy in forum Queries
    Replies: 4
    Last Post: 06-12-2010, 01:13 AM
  2. Replies: 1
    Last Post: 02-03-2010, 09:17 PM
  3. Replies: 3
    Last Post: 12-10-2009, 02:16 PM
  4. Replies: 3
    Last Post: 08-06-2009, 11:49 PM
  5. Query to Display Tables & Fields
    By foxerator in forum Queries
    Replies: 0
    Last Post: 04-24-2008, 09:57 AM

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