John
Gross Order Total and Sales tax Total are off by a couple cents. I changed
the Clng to CCur, changed the datatype to currency with 2 decimal places.
Still not sure how to use the Round Function in all this. Maybe with seeing
the structure below you can give me a little more insight. Thanks again.
----Order Details Table----
OrderDetailID - Primary Key - AutoNumber - Long Integer
OrderID - Text
ProductID - Text
Quantity - Number - Double - Decimal 0
UnitPrice - Currency - Format Currency - Decimal 2
CCSPrice - Currency - Format Currency - Decimal 2
Discount - Currency - Format Currency - Decimal 2
----Order Table----
OrderID - Text
CustomerID - Number - Long Integer - Decimal Auto
EmployeeID - Long Integer - Decimal Auto
OrderDate - Date/Time - Short Date
PurchaseOrderNumber - Text
ShipName - Text
ShipAddress - Text
ShipCity - Text
ShipStateOfProvince - Text
ShipPostalCode - Text
ShipCountry - Text
ShipPhoneNumber - Text
ShipDate - Date/Time - Short Date
ShippingmethodID - Number - Long Integer 0 Deciaml Auto
FreightCharge - Currency - Decimal 2
CityTaxRate - Currency - Format Percent - Deciaml 2 - Default value 0
StateTaxRate - Currency - Format Percent - Deciaml 2 - Default value 0
SalesTaxRate - Currency - Format Percent - Deciaml 2 - Default value 0
ARDetailID - AutoNumber - Long Integer
----Main Report Query----
SELECT DISTINCTROW Orders.OrderID, Orders.CustomerID,
Sum(CCur([Quantity]*[UnitPrice])*100)/100+Sum(CCur([Quantity]*[UnitPrice]*[SalesTaxRate])*100)/100+First(CCur([FreightCharge])*100)/100
AS [Gross Order Total], Sum(CCur([Quantity]*[UnitPrice])*100)/100 AS [Net
Order Total], Sum(CCur([Quantity]*[UnitPrice]*[SalesTaxRate])*100)/100 AS
[Sales Tax Total], Orders.FreightCharge,
Sum(CCur([Quantity]*[UnitPrice]*[CityTaxRate])*100)/100 AS [City Tax Total],
Sum(CCur([Quantity]*[UnitPrice]*[StateTaxRate])*100)/100 AS [State Tax
Total], Sum(CCur([Quantity]*[CCSPrice]-[Discount])*100)/100 AS CCSPricing,
Orders.OrderDate,
Sum(CCur([Quantity]*[UnitPrice])*100)/100-Sum(CCur([Quantity]*[CCSPrice])*100)/100+Sum(CCur([Discount])*100)/100
AS Profit
FROM Orders LEFT JOIN [Order Details] ON Orders.OrderID = [Order
Details].OrderID
GROUP BY Orders.OrderID, Orders.CustomerID, Orders.FreightCharge,
Orders.OrderDate
HAVING (((Orders.OrderDate)>=[forms]![Report Date Range]![Beginning Order
Date] And (Orders.OrderDate)<=[forms]![Report Date Range]![Ending Order
Date]));
In the Main Report Query, each record for Gross Order Total is showing 4
numbers to the right of the decimal.
----Main Report----
Record Source - Main Report Query
Filter on - No
Order By On - No
Sorting and Grouping - OrderDate - Ascending
Group Header - No
Group Footer - No
Group on Each Value
Group Interval - 1
Keep Together No
In Report Detail I have Gross Order Total and Sales Tax Total which seem to
calculate fine...I think. The calculations are incorrect when I Sum those 2
in the Report footer. This is where I am seeing it off by 1 or 2 pennies.
=Sum([Gross Order Total]) - Running Sum - No
=Sum([Sales Tax Total]) - Running Sum - No
John W. Vinson said:
John:
I changed the datatype to currency in my table but I am not doing
something
right in the query with the use of Round in the calculation.
SELECT DISTINCTROW Orders.OrderID, Orders.CustomerID,
Sum(CLng(nz([Quantity]*[UnitPrice])*100)/100)+Sum(CLng(nz([Quantity]*[UnitPrice]*[SalesTaxRound])*100)/100)+First(CLng(nz([FreightCharge])*100)/100)
AS [Order Total]
FROM (Orders INNER JOIN [SalesTaxRound Query] ON Orders.OrderID =
[SalesTaxRound Query].OrderID) LEFT JOIN [Order Details] ON Orders.OrderID
=
[Order Details].OrderID
GROUP BY Orders.OrderID, Orders.CustomerID;
----SalesTaxRound Query----
SELECT Round([SalesTaxRate],2) AS SalesTaxRound, Orders.OrderID
FROM Orders
GROUP BY Round([SalesTaxRate],2), Orders.OrderID;
Change all your CLng to CCur for starters. You can use Round() rather than
the
*100)/100 stuff - are you trying to round to integer dollars or what? You
say
you're "not doing something right" - what's wrong? Are you getting error
messages, wrong results, or what???
John W. Vinson [MVP]