R
Rob Parker
This should be so simple, but I'm about to tear my hair out.
I have a crosstab query based on a table, left joined to a query which
selects distinct FYs from another table, so that all FYs will show as
column headings. Pretty standard stuff. The strange thing about this
is that the crosstab query returns a single blank record, in addition
to the records I expect. But even stranger is that, if I add a WHERE
clause to the query, the query no longer returns all the fields from
the left-joined FY query, so column headings which have no data are
now missing.
Details:
Using Access 2003 SP3, with Jet 4.0, running on Win PR Pro. Database
has been compact/repaired, and decompiled.
qryFY:
SELECT DISTINCT tblMonthlyDatasets.FY, getFYString([FY]) AS DisplayFY
FROM tblMonthlyDatasets
ORDER BY tblMonthlyDatasets.FY;
qryFY returns the expected dataset (no blank record). The crosstab
uses the FY field (long integer) to link to tblBudgets, and uses
DisplayFY (a string showing FY in a format such as "2009-10") for the
column headings; however, using FY itself as the column heading does
not fix the problem.
tblBudgets:
Country - text
Item - text
FY - long integer
Amount - currency
IsCurrent - yes/no
XTab which returns blank record:
TRANSFORM Sum(tblBudgets.Amount) AS SumOfAmount
SELECT tblBudgets.Country, tblBudgets.Item, Sum(tblBudgets.Amount) AS
TotalAmount
FROM qryFY LEFT JOIN tblBudgets ON qryFY.FY = tblBudgets.FY
GROUP BY tblBudgets.Country, tblBudgets.Item
PIVOT qryFY.DisplayFY;
XTab which fails to return all column headings:
TRANSFORM Sum(tblBudgets.Amount) AS SumOfAmount
SELECT tblBudgets.Country, tblBudgets.Item, Sum(tblBudgets.Amount) AS
TotalAmount
FROM qryFY LEFT JOIN tblBudgets ON qryFY.FY = tblBudgets.FY
WHERE (((tblBudgets.IsCurrent)=True))
GROUP BY tblBudgets.Country, tblBudgets.Item
PIVOT qryFY.DisplayFY;
Any ideas?
TIA,
Rob
I have a crosstab query based on a table, left joined to a query which
selects distinct FYs from another table, so that all FYs will show as
column headings. Pretty standard stuff. The strange thing about this
is that the crosstab query returns a single blank record, in addition
to the records I expect. But even stranger is that, if I add a WHERE
clause to the query, the query no longer returns all the fields from
the left-joined FY query, so column headings which have no data are
now missing.
Details:
Using Access 2003 SP3, with Jet 4.0, running on Win PR Pro. Database
has been compact/repaired, and decompiled.
qryFY:
SELECT DISTINCT tblMonthlyDatasets.FY, getFYString([FY]) AS DisplayFY
FROM tblMonthlyDatasets
ORDER BY tblMonthlyDatasets.FY;
qryFY returns the expected dataset (no blank record). The crosstab
uses the FY field (long integer) to link to tblBudgets, and uses
DisplayFY (a string showing FY in a format such as "2009-10") for the
column headings; however, using FY itself as the column heading does
not fix the problem.
tblBudgets:
Country - text
Item - text
FY - long integer
Amount - currency
IsCurrent - yes/no
XTab which returns blank record:
TRANSFORM Sum(tblBudgets.Amount) AS SumOfAmount
SELECT tblBudgets.Country, tblBudgets.Item, Sum(tblBudgets.Amount) AS
TotalAmount
FROM qryFY LEFT JOIN tblBudgets ON qryFY.FY = tblBudgets.FY
GROUP BY tblBudgets.Country, tblBudgets.Item
PIVOT qryFY.DisplayFY;
XTab which fails to return all column headings:
TRANSFORM Sum(tblBudgets.Amount) AS SumOfAmount
SELECT tblBudgets.Country, tblBudgets.Item, Sum(tblBudgets.Amount) AS
TotalAmount
FROM qryFY LEFT JOIN tblBudgets ON qryFY.FY = tblBudgets.FY
WHERE (((tblBudgets.IsCurrent)=True))
GROUP BY tblBudgets.Country, tblBudgets.Item
PIVOT qryFY.DisplayFY;
Any ideas?
TIA,
Rob