
Originally Posted by
mike60smart
Hi Vinay
You should think Access which would display your data as shown in the attached screenshot.
That's how the UnencodeColumns demo which I attached earlier recasts the incorrectly modelled data. It then requires a simple crosstab query to return the data in the OP's desired format:
Code:
TRANSFORM MIN(StoreStock_Vals.Quantity)
SELECT
Stocks_Vals.Stock
FROM
Stocks_Vals
INNER JOIN (
Stores
INNER JOIN StoreStock_Vals ON Stores.StoreID = StoreStock_Vals.StoreID
) ON Stocks_Vals.StockID = StoreStock_Vals.StockID
WHERE
DSUM (
"Quantity",
"StoreStock_Vals",
"StoreID = " & Stores.StoreID
) > 0
GROUP BY
Stocks_Vals.Stock
PIVOT Stores.Store;
Normally a correlated subquery would be used to restrict the result table to those stores where the quantity totals more than zero, but I couldn't get that to work in a crosstab query, so have had to resort to calling the VBA DSum function.