Sum of SQL Statement

D

DS

I need to get the Sum of Expr4 where Taxed is True.....How would I do
this? I need to pass it to a textbox on a form> This is the code of a
listbox that shows the current records, Expr4 being the price of the Item.
Any help appreciated.
Thanks
DS

Private Sub Form_Current()
With Me.ListOrders
..RowSource = "SELECT SalesDetails.SalesID, SalesDetails.LineID,
SalesDetails.Quantity, Items.ItemName,
CCur(IIf([Expr3]>0,[Expr1]-[Expr3],[Expr2])) AS Expr4, Items.ItemType,
SalesDetails.Sent,
CCur(Choose([PriceLevel],[Price1],[Price2],[Price3],[Price4],[Price5],[Price6],[Price7])*[Quantity])
AS Expr1, SalesDetails.MenuNum, Items.Taxed, Items.Inclusive,
Items.NoTax, CCur(Nz([Expr1]-[DiscountAmount],[Expr1])) AS Expr2,
CCur(Nz([Expr1]*[DiscountPercent],0)) AS Expr3 " & _
"FROM Items INNER JOIN ((DiscountTypes RIGHT JOIN SalesDetails ON
DiscountTypes.DiscountID = SalesDetails.DiscountType) LEFT JOIN Menus ON
SalesDetails.MenuNum = Menus.MenuID) ON Items.ItemID =
SalesDetails.ItemID " & _
"WHERE (((SalesDetails.SalesID) = [Forms]![CheckPreview]![SalesID]))" & _
"ORDER BY SalesDetails.LineID, Items.ItemName, Items.ItemType;"
..Requery
End With
End Sub
 
J

John Vinson

I need to get the Sum of Expr4 where Taxed is True.....How would I do
this? I need to pass it to a textbox on a form> This is the code of a
listbox that shows the current records, Expr4 being the price of the Item.
Any help appreciated.
Thanks
DS

Your query doesn't CONTAIN an Expr4... I'm confused.

Try

Sum(IIF([Taxed], [PriceOfItem], 0))


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SQL Rowsource 2
SQL Woes 4

Top