leafsrock100
Registered User.
- Local time
- Today, 04:53
- Joined
- Jul 29, 2010
- Messages
- 17
I have an inventory report that is based on a user inputted date range on a form. When I click preview on the form, the report opens via a macro and sometimes shows an "#Error". However, when I click design view and then print preview again, the report queries the desired results.
How can I program it so that the "#Error" does not show?
The following is the SQL statement if that helps:
SELECT DISTINCTROW Products.ProductID, Products.ProductName, [Beginning Inventory].UnitType, [Beginning Inventory].[Beginning Inventory], Purchases.Purchases, Sales.Sales, nz([Beginning Inventory],0)+nz([Purchases],0)-nz([Sales],0) AS [Ending Inventory], [Beginning Inventory].BegUnitPrice, Format(nz([Beginning Inventory]*[BegUnitPrice],0),"$0.00") AS BegTotal, Format(Sum(nz([Beginning Inventory]*[BegUnitPrice],0)+nz([Purchases]*[PurchasePrice],0))/Sum(nz([Purchases],0)+nz([Beginning Inventory],0)),"$0.00") AS [Ending Unit Price], Format(nz([Ending Unit Price]*[Ending inventory],0),"$0.00") AS [End Total]
FROM (Units INNER JOIN (((Products INNER JOIN [Inventory Transactions] ON Products.ProductID = [Inventory Transactions].ProductID) INNER JOIN [Beginning Inventory] ON Products.ProductID = [Beginning Inventory].ProductID) INNER JOIN Purchases ON Products.ProductID = Purchases.ProductID) ON Units.UnitID = [Inventory Transactions].UnitID) INNER JOIN Sales ON Products.ProductID = Sales.ProductID
GROUP BY Products.ProductID, Products.ProductName, [Beginning Inventory].UnitType, [Beginning Inventory].[Beginning Inventory], Purchases.Purchases, Sales.Sales, [Beginning Inventory].BegUnitPrice;
How can I program it so that the "#Error" does not show?
The following is the SQL statement if that helps:
SELECT DISTINCTROW Products.ProductID, Products.ProductName, [Beginning Inventory].UnitType, [Beginning Inventory].[Beginning Inventory], Purchases.Purchases, Sales.Sales, nz([Beginning Inventory],0)+nz([Purchases],0)-nz([Sales],0) AS [Ending Inventory], [Beginning Inventory].BegUnitPrice, Format(nz([Beginning Inventory]*[BegUnitPrice],0),"$0.00") AS BegTotal, Format(Sum(nz([Beginning Inventory]*[BegUnitPrice],0)+nz([Purchases]*[PurchasePrice],0))/Sum(nz([Purchases],0)+nz([Beginning Inventory],0)),"$0.00") AS [Ending Unit Price], Format(nz([Ending Unit Price]*[Ending inventory],0),"$0.00") AS [End Total]
FROM (Units INNER JOIN (((Products INNER JOIN [Inventory Transactions] ON Products.ProductID = [Inventory Transactions].ProductID) INNER JOIN [Beginning Inventory] ON Products.ProductID = [Beginning Inventory].ProductID) INNER JOIN Purchases ON Products.ProductID = Purchases.ProductID) ON Units.UnitID = [Inventory Transactions].UnitID) INNER JOIN Sales ON Products.ProductID = Sales.ProductID
GROUP BY Products.ProductID, Products.ProductName, [Beginning Inventory].UnitType, [Beginning Inventory].[Beginning Inventory], Purchases.Purchases, Sales.Sales, [Beginning Inventory].BegUnitPrice;