I have made a query from Crosstab Query to make the "Stock Summary Balance" but if one of the column Heading balance is not available then it shows error message becuase of null stock otherwise the query is working with balances.
Error Message: The Microsoft office database engine does not recognize '[OpeningStock]' as a valid field name or expression
(Image is attached herewith)
Note: This message is coming because of the null stock,
How could I avoid this error to happen? If there is other way to get Stock summary balance in crosstab query then let me know please.
The detail of the queries are as under;
a. Columns in Query made from corsstab query: ItemsPK, ItemsListName, Opening, Purchases, Transfers, Adjustments, StockBalance, AvgUsage
(Images are attached herewith)
b. Columns in Crosstab Query: ItemsPk, ItemsListName, Stock, SumofStock_In_Out
(Images are attached herewith)
c. Union Query:
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate, TranTypePK, "OpeningStock" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate)<=DateSerial(Year(Date()),Month(Date()),0)))
ORDER BY ItemsPK
UNION ALL
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate,TranTypePK, "NetPurchases" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate) Between DateSerial(Year(Date()),Month(Date())+1,1) And DateSerial(Year(Date()),Month(Date()),0)) AND ((TranTypePK)<=2))
UNION ALL
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate, TranTypePK, "NetTransfers" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate) Between DateSerial(Year(Date()),Month(Date())+1,1) And DateSerial(Year(Date()),Month(Date()),0)) AND ((TranTypePK)>=3 And (TranTypePK)<=5))
UNION ALL
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate, TranTypePK, "MonthlyAdjustments" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate) Between DateSerial(Year(Date()),Month(Date())+1,1) And DateSerial(Year(Date()),Month(Date()),0)) AND ((TranTypePK)=6));
(Image is attached herewith)
Kindly suggest the solution.
Error Message: The Microsoft office database engine does not recognize '[OpeningStock]' as a valid field name or expression
(Image is attached herewith)
Note: This message is coming because of the null stock,
How could I avoid this error to happen? If there is other way to get Stock summary balance in crosstab query then let me know please.
The detail of the queries are as under;
a. Columns in Query made from corsstab query: ItemsPK, ItemsListName, Opening, Purchases, Transfers, Adjustments, StockBalance, AvgUsage
(Images are attached herewith)
b. Columns in Crosstab Query: ItemsPk, ItemsListName, Stock, SumofStock_In_Out
(Images are attached herewith)
c. Union Query:
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate, TranTypePK, "OpeningStock" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate)<=DateSerial(Year(Date()),Month(Date()),0)))
ORDER BY ItemsPK
UNION ALL
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate,TranTypePK, "NetPurchases" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate) Between DateSerial(Year(Date()),Month(Date())+1,1) And DateSerial(Year(Date()),Month(Date()),0)) AND ((TranTypePK)<=2))
UNION ALL
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate, TranTypePK, "NetTransfers" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate) Between DateSerial(Year(Date()),Month(Date())+1,1) And DateSerial(Year(Date()),Month(Date()),0)) AND ((TranTypePK)>=3 And (TranTypePK)<=5))
UNION ALL
SELECT ItemsPK, ItemsListName, Sum(Stock_In_Out) AS SumOfStock_In_Out, TranDate, TranTypePK, "MonthlyAdjustments" AS Stock
FROM qryTransactionsExtended
GROUP BY ItemsPK, ItemsListName, TranDate, TranTypePK
HAVING (((TranDate) Between DateSerial(Year(Date()),Month(Date())+1,1) And DateSerial(Year(Date()),Month(Date()),0)) AND ((TranTypePK)=6));
(Image is attached herewith)
Kindly suggest the solution.
Attachments
-
ErrorMessage1.GIF33 KB · Views: 121
-
ErrorMessage2.GIF30.2 KB · Views: 107
-
Crosstab_Query.GIF180.9 KB · Views: 114
-
Crosstab_Query_1.GIF49.4 KB · Views: 112
-
qry_from_crosstab_Query.GIF248.4 KB · Views: 106
-
qry_from_crosstab_Query_1.GIF55.1 KB · Views: 111
-
Union_Query_Results.GIF87.8 KB · Views: 113
Last edited: