Results 1 to 3 of 3
  1. #1
    PinkDuster's Avatar
    PinkDuster is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2017
    Location
    Cleveland area
    Posts
    65

    Two calculated fields in the same query are resulting in an "Enter Parameter Value"

    I created a query to calculate and summarize total line item cost, and total order cost by order for each customer.

    SELECT tblCustomers.CustName, tblOrders.OrderID, tblOrders.OrderDate, Sum(tblOrderDetails.[Quantity]*[SoldAsPrice]) AS LineTotal, tblOrders.OrderShippingAmt, [LineTotal]+[OrderShippingAmt] AS OrderTotal
    FROM (tblCustomers INNER JOIN tblOrders ON tblCustomers.CustID = tblOrders.LkupOrderCustID) INNER JOIN tblOrderDetails ON tblOrders.OrderID = tblOrderDetails.fkOrderID
    GROUP BY tblCustomers.CustName, tblOrders.OrderID, tblOrders.OrderDate, tblOrders.OrderShippingAmt, [LineTotal]+[OrderShippingAmt]
    ORDER BY tblOrders.OrderID;

    When I run the query, I get the following error, but when I click OK, the query still runs, and the results are as expected. I have done the preliminary review of the expressions, but I can't find a problem.



    Click image for larger version. 

Name:	qryParameterError.png 
Views:	9 
Size:	16.0 KB 
ID:	32152Click image for larger version. 

Name:	qryResults.png 
Views:	9 
Size:	29.5 KB 
ID:	32153

    PS., thank you to everyone who has pointed out that I can calculate totals in queries, rather than saving them to tables, I just need to get over this hurdle.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you cannot create LINETOTAL field AND use it elsewhere in the same query.

    Either make 2 queries:
    Q1 creates LINETOTAL , then Q2 uses it
    or
    in your single query above, use the formula in every instance: Sum(tblOrderDetails.[Quantity]*[SoldAsPrice]) +ShippingOrder

  3. #3
    PinkDuster's Avatar
    PinkDuster is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2017
    Location
    Cleveland area
    Posts
    65
    Thank you, I tried both approaches however could not make the single query work because of the aggregation constraints (summing various lines by Order number).

    I used 2 queries, and get the correct results (with the Shipping Amount added to the sum of the lines).

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

Similar Threads

  1. Replies: 5
    Last Post: 05-06-2016, 11:43 AM
  2. Replies: 6
    Last Post: 12-22-2015, 09:49 PM
  3. Replies: 5
    Last Post: 06-24-2015, 11:46 AM
  4. Replies: 8
    Last Post: 07-15-2014, 05:56 PM
  5. Replies: 1
    Last Post: 08-12-2013, 09:34 AM

Tags for this Thread

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