When I run a report with the source as a crosstab query i get an error message:
"cannot use the crosstab of a non-fixed column as a sub query"
what does this mean?
Crosstab query as record source of report
-
- 3StarLounger
- Posts: 247
- Joined: 05 Nov 2012, 19:40
-
- 3StarLounger
- Posts: 247
- Joined: 05 Nov 2012, 19:40
Re: Crosstab query as record source of report
this is my query:
TRANSFORM Sum(M_EExpensesDetails.ExpenseAmount) AS SumOfExpenseAmount
SELECT [M_Info].[Fname] & " " & [M_Info].[Lname] AS Ename
FROM M_EExpensesDetails INNER JOIN M_Info ON M_EExpensesDetails.ID = M_Info.ID
GROUP BY [M_Info].[Fname] & " " & [M_Info].[Lname]
PIVOT M_EExpensesDetails.ExpenseType;
TRANSFORM Sum(M_EExpensesDetails.ExpenseAmount) AS SumOfExpenseAmount
SELECT [M_Info].[Fname] & " " & [M_Info].[Lname] AS Ename
FROM M_EExpensesDetails INNER JOIN M_Info ON M_EExpensesDetails.ID = M_Info.ID
GROUP BY [M_Info].[Fname] & " " & [M_Info].[Lname]
PIVOT M_EExpensesDetails.ExpenseType;
-
- Administrator
- Posts: 78655
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Crosstab query as record source of report
The column headings of a crosstab query can in theory change over time, if the values of the column heading field changes.
A report, on the other hand, has fixed control sources for its text boxes etc.
There are two ways around this:
1) If the column headings actually won't change, you can fix them by specifying the Column Headings property of the crosstab query:
You can enter the column headings here in the order that you want them to appear, separated by commas (and enclosed in quotation marks if necessary).
2) If the column headings may change, you need to create a dynamic crosstab report; this requires quite complicated VBA code.
A report, on the other hand, has fixed control sources for its text boxes etc.
There are two ways around this:
1) If the column headings actually won't change, you can fix them by specifying the Column Headings property of the crosstab query:
You can enter the column headings here in the order that you want them to appear, separated by commas (and enclosed in quotation marks if necessary).
2) If the column headings may change, you need to create a dynamic crosstab report; this requires quite complicated VBA code.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78655
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Crosstab query as record source of report
The SQL for the query with fixed column headings would be
TRANSFORM Sum(M_EExpensesDetails.ExpenseAmount) AS SumOfExpenseAmount
SELECT [M_Info].[Fname] & " " & [M_Info].[Lname] AS Ename
FROM M_EExpensesDetails INNER JOIN M_Info ON M_EExpensesDetails.ID = M_Info.ID
GROUP BY [M_Info].[Fname] & " " & [M_Info].[Lname]
PIVOT M_EExpensesDetails.ExpenseType In ("Travel", "Lodging", "Food")
The categories "Travel" etc. are just examples of course.
TRANSFORM Sum(M_EExpensesDetails.ExpenseAmount) AS SumOfExpenseAmount
SELECT [M_Info].[Fname] & " " & [M_Info].[Lname] AS Ename
FROM M_EExpensesDetails INNER JOIN M_Info ON M_EExpensesDetails.ID = M_Info.ID
GROUP BY [M_Info].[Fname] & " " & [M_Info].[Lname]
PIVOT M_EExpensesDetails.ExpenseType In ("Travel", "Lodging", "Food")
The categories "Travel" etc. are just examples of course.
Best wishes,
Hans
Hans