strange sql error msg

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • n8kindt
    New Member
    • Mar 2008
    • 221

    strange sql error msg

    here's my sql code:

    [CODE=sql]SELECT ActivityLog.Dat eSignedIN, Sum(ActivityLog .ProductPurchas ed) AS SumOfProductPur chased, Sum(ActivityLog .ProductAdj) AS SumOfProductAdj , Sum(ActivityLog .TaxPercent) AS SumOfTaxPercent , Sum(ActivityLog .Subtotal) AS SumOfSubtotal, Sum(ActivityLog .GrandTotal) AS SumOfGrandTotal , Sum(ActivityLog .TransactionTyp e) AS SumOfTransactio nType, Sum(Round((((([ProductPurchase d] + Nz([ProductAdj],0))*([TaxPercent]*2)) + (([Subtotal]-([ProductPurchase d] + Nz([ProductAdj],0)))*[TaxPercent]) + [Subtotal])+Nz([Shipping],0))+0.000001,2 )) AS ExpectedGrandTo tal, Sum(Round(Nz([GrandTotal],[ExpectedGrandTo tal]),2)) AS FinalGT, Sum(ActivityLog .Shipping) AS SumOfShipping, Sum(Round((([TaxPercent]*([Subtotal] - ([ProductPurchase d] + Nz([ProductAdj],0)))) + (2*([ProductPurchase d] + Nz([ProductAdj],0))*[TaxPercent]) + 0.00000001),2)) AS ExpectedTax, Sum(ActivityLog .ActualTax) AS SumOfActualTax, Sum(Round(Nz([ActualTax],[ExpectedTax]),2)) AS FinalTax, Sum([subtotal]-[productpurchase d]) AS Supplies
    FROM ActivityLog
    WHERE (((Month([DateSignedIN]))=[Forms]![frmDRInput]![Month]) AND ((Year([DateSignedIN]))=[Forms]![frmDRInput]![Year]))
    GROUP BY ActivityLog.Dat eSignedIN;[/CODE]

    Here's the error msg:
    Subqueries cannot be used in the expression (Round(Nz([GrandTotal],[ExpectedGrandTo tal]),2)).

    if i hide the 'FinalGT' and the 'ExpectedTax' columns (FinalGT is the one with the troublesome code--i have to hide ExpectedTax, too b/c it returns a similar error msg), it runs fine.... which is wierd b/c 'ExpectedGT' and 'FinalGT' use the same format but they run fine... uhhhh why am i getting this error msg???
    Last edited by nico5038; May 9 '08, 05:50 AM. Reason: Query too wide, added some spaces
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    I'm afraid you can't use the "as" fields in the same query. You would have to replace them by the calculation used to create them.
    An alternative is to save the query without this field and use the saved query in a new query where you place the calculation.

    Nic;o)

    Comment

    • n8kindt
      New Member
      • Mar 2008
      • 221

      #3
      Originally posted by nico5038
      I'm afraid you can't use the "as" fields in the same query. You would have to replace them by the calculation used to create them.
      An alternative is to save the query without this field and use the saved query in a new query where you place the calculation.

      Nic;o)
      that makes sense. thanks nico!

      Comment

      Working...