P
Pete
Hi,
I have a problem with a crosstab query that sums orders and available
inventory for plants at a nursery according to pot size (rows), and colors
(columns). This query feeds the pages of a tab control in a form that has
customer info at the main form level with order and order detail subforms.
The main form has combo boxes for 'Customer Category' and 'Season'. The tab
control has pages to display orders for each 'Customer Category' and one for
'Inventory Available', etc. - each fed by a version of the following with
minor variations to suit the needs of the tab selected.
TRANSFORM Sum([Order Details].Quantity) AS SumOfQuantity
SELECT PotSizes.Size
FROM PotSizes INNER JOIN (((CustomerCategories INNER JOIN Customers ON
CustomerCategories.CategoryID = Customers.Category) INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN ((Defaults INNER JOIN
Crops ON Defaults.Crop = Crops.CropID) INNER JOIN ([Order Details] INNER
JOIN Colors ON [Order Details].ColorID = Colors.ColorID) ON Crops.CropID =
[Order Details].CropID) ON Orders.OrderID = [Order Details].OrderID) ON
PotSizes.PotSizeID = [Order Details].PotSizeID
WHERE ((([Order Details].CropID)=[Defaults]![Crop]) AND
((Customers.Category)=[Forms]![Customer Orders]![txtCategory]) AND
((Year([Order Date]))=[Forms]![Customer Orders]![cboSeason]))
GROUP BY PotSizes.Size
PIVOT Colors.Color In ("Red","White","Pink","Marble","Burgundy","Plum
Pudding","Jingle Bells","WR red","WR white","WR pink","WR
marble","Monet","Peppermint");
This has worked very well for a couple of years, and with the 'Season'
selection box on the main form, we can just keep throwing everything into
the same tables from year to year without need to separate one year's orders
from another, as the only thing that shows up is the orders for the season
selected. As time goes by, though, some of the colors in the inventory have
changed and been discontinued, and I'd like to alter this crosstab query so
the colors in the tab control will be generated rather than coded in the
'IN' term at the end of the query - something like this
TRANSFORM Sum([Order Details].Quantity) AS SumOfQuantity
SELECT PotSizes.Size
FROM PotSizes INNER JOIN (((CustomerCategories INNER JOIN Customers ON
CustomerCategories.CategoryID = Customers.Category) INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN ((Defaults INNER JOIN
Crops ON Defaults.Crop = Crops.CropID) INNER JOIN ([Order Details] INNER
JOIN Colors ON [Order Details].ColorID = Colors.ColorID) ON Crops.CropID =
[Order Details].CropID) ON Orders.OrderID = [Order Details].OrderID) ON
PotSizes.PotSizeID = [Order Details].PotSizeID
WHERE ((([Order Details].CropID)=[Defaults]![Crop]) AND
((Customers.Category)=[Forms]![Customer Orders]![txtCategory]) AND
((Year([Order Date]))=[Forms]![Customer Orders]![cboSeason]))
GROUP BY PotSizes.Size
PIVOT Colors.Color;
For some reason that I've been unable to discover this results in the
following error:
'The Microsoft Jet database engine does not recognize [Forms]![Customer
Orders]![cboSeason] as a valid field name or expression.'
If I delete the season criteria as follows, it works fine.
TRANSFORM Sum([Order Details].Quantity) AS SumOfQuantity
SELECT PotSizes.Size
FROM PotSizes INNER JOIN (((CustomerCategories INNER JOIN Customers ON
CustomerCategories.CategoryID = Customers.Category) INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN ((Defaults INNER JOIN
Crops ON Defaults.Crop = Crops.CropID) INNER JOIN ([Order Details] INNER
JOIN Colors ON [Order Details].ColorID = Colors.ColorID) ON Crops.CropID =
[Order Details].CropID) ON Orders.OrderID = [Order Details].OrderID) ON
PotSizes.PotSizeID = [Order Details].PotSizeID
WHERE ((([Order Details].CropID)=[Defaults]![Crop]) AND
((CustomerCategories.CategoryName)="Special Order"))
GROUP BY PotSizes.Size
PIVOT Colors.Color;
Any ideas why Access can recognize the reference to [Forms]![Customer
Orders]![cboSeason] when the "IN" clause is included and not without it?
I have a problem with a crosstab query that sums orders and available
inventory for plants at a nursery according to pot size (rows), and colors
(columns). This query feeds the pages of a tab control in a form that has
customer info at the main form level with order and order detail subforms.
The main form has combo boxes for 'Customer Category' and 'Season'. The tab
control has pages to display orders for each 'Customer Category' and one for
'Inventory Available', etc. - each fed by a version of the following with
minor variations to suit the needs of the tab selected.
TRANSFORM Sum([Order Details].Quantity) AS SumOfQuantity
SELECT PotSizes.Size
FROM PotSizes INNER JOIN (((CustomerCategories INNER JOIN Customers ON
CustomerCategories.CategoryID = Customers.Category) INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN ((Defaults INNER JOIN
Crops ON Defaults.Crop = Crops.CropID) INNER JOIN ([Order Details] INNER
JOIN Colors ON [Order Details].ColorID = Colors.ColorID) ON Crops.CropID =
[Order Details].CropID) ON Orders.OrderID = [Order Details].OrderID) ON
PotSizes.PotSizeID = [Order Details].PotSizeID
WHERE ((([Order Details].CropID)=[Defaults]![Crop]) AND
((Customers.Category)=[Forms]![Customer Orders]![txtCategory]) AND
((Year([Order Date]))=[Forms]![Customer Orders]![cboSeason]))
GROUP BY PotSizes.Size
PIVOT Colors.Color In ("Red","White","Pink","Marble","Burgundy","Plum
Pudding","Jingle Bells","WR red","WR white","WR pink","WR
marble","Monet","Peppermint");
This has worked very well for a couple of years, and with the 'Season'
selection box on the main form, we can just keep throwing everything into
the same tables from year to year without need to separate one year's orders
from another, as the only thing that shows up is the orders for the season
selected. As time goes by, though, some of the colors in the inventory have
changed and been discontinued, and I'd like to alter this crosstab query so
the colors in the tab control will be generated rather than coded in the
'IN' term at the end of the query - something like this
TRANSFORM Sum([Order Details].Quantity) AS SumOfQuantity
SELECT PotSizes.Size
FROM PotSizes INNER JOIN (((CustomerCategories INNER JOIN Customers ON
CustomerCategories.CategoryID = Customers.Category) INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN ((Defaults INNER JOIN
Crops ON Defaults.Crop = Crops.CropID) INNER JOIN ([Order Details] INNER
JOIN Colors ON [Order Details].ColorID = Colors.ColorID) ON Crops.CropID =
[Order Details].CropID) ON Orders.OrderID = [Order Details].OrderID) ON
PotSizes.PotSizeID = [Order Details].PotSizeID
WHERE ((([Order Details].CropID)=[Defaults]![Crop]) AND
((Customers.Category)=[Forms]![Customer Orders]![txtCategory]) AND
((Year([Order Date]))=[Forms]![Customer Orders]![cboSeason]))
GROUP BY PotSizes.Size
PIVOT Colors.Color;
For some reason that I've been unable to discover this results in the
following error:
'The Microsoft Jet database engine does not recognize [Forms]![Customer
Orders]![cboSeason] as a valid field name or expression.'
If I delete the season criteria as follows, it works fine.
TRANSFORM Sum([Order Details].Quantity) AS SumOfQuantity
SELECT PotSizes.Size
FROM PotSizes INNER JOIN (((CustomerCategories INNER JOIN Customers ON
CustomerCategories.CategoryID = Customers.Category) INNER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID) INNER JOIN ((Defaults INNER JOIN
Crops ON Defaults.Crop = Crops.CropID) INNER JOIN ([Order Details] INNER
JOIN Colors ON [Order Details].ColorID = Colors.ColorID) ON Crops.CropID =
[Order Details].CropID) ON Orders.OrderID = [Order Details].OrderID) ON
PotSizes.PotSizeID = [Order Details].PotSizeID
WHERE ((([Order Details].CropID)=[Defaults]![Crop]) AND
((CustomerCategories.CategoryName)="Special Order"))
GROUP BY PotSizes.Size
PIVOT Colors.Color;
Any ideas why Access can recognize the reference to [Forms]![Customer
Orders]![cboSeason] when the "IN" clause is included and not without it?