views:

750

answers:

1

I want to pull data with an MS Access crosstab query so I can bind it to a report. When I load the page I get a Run-time error'3637': Cannot use the crosstab of a non-fixed column as a subquery.

I would like a way to get back a fixed grid when I run the query and if the cell is null display a zero.

+1  A: 

Subquery? That's one of my weaknesses when it comes to Access so I can't help you there. I'd suggest posting the SQL of the query though so others can take a look. Also what happens when you run the query?

The following is a query that I'm using to give me costs for the last ten years for a given unit. TRANSFORM Sum(ServiceRecords.srTotalCost) AS AnnualCost SELECT ServiceRecords.srEquipmentID FROM ServiceRecords GROUP BY ServiceRecords.srEquipmentID PIVOT "C" & DateDiff("yyyy",[srServiceDate],Date()) In ("C9","C8","C7","C6","C5","C4","C3","C2","C1","C0");

The trick is after the PIVOT. As I want the last ten years worth of data the "C" & DateDiff portion sets up a string variable call C0 to C9. The portion after the In tells which column to stuff things into.

Another query which pulls in data about the Equipment calls this query. The term we generally use for such is stacked queries.

If this isn't enough to get you going please indicate what type of data you are trying to create a cross tab.

Fellow Access MVP, Allen Browne has a good page on this topic. Crosstab query techniques

Tony Toews
Ok, I see what you're saying. Basically I can use the In ("x","y","z") with the desired column names. That works ok, but is there a way to have generate those from the rows of a lookup table automatically?
Bob
See the last line of my just edited posting.
Tony Toews
That's a great post. Thanks a lot.
Bob