|
Question : Report from Crosstab Query
|
|
I want to change the Recordsource property of my report dynamically through VBA. When I try to use my SQL statement as the Recordsource I get a syntax error. I believe this is caused by the "PIVOT" clause in the SQL statement. My query is named Crosstab2 and if I use "Crosstab2" as the RecordSource the report opens. Crosstab2 contains a WHERE clause that restricts the dates that my report displays to a date range. My problem is how to alter the query to allow for different date ranges. Normally, I would create a string such as
strSQL = "SELECT ..... WHERE "
and then plug this string in as the RecordSource. Since the word PIVOT is not a valid SQL statement I cannot do it this way. I can physically change the date range in the query Crosstab2 and then open the report and it is fine. How do I accomplish the same thing in code?
|
|
Answer : Report from Crosstab Query
|
|
The Fixed Column Headings limit the number of fields to only those values so yes if you have 26 values being returned you will need a fixed column heading for each value.
rvooijs , modifying the SQL of the querydef does work except the you have variable field/column names in your query so you would also have to play around with your control sources in your report, that is why it is simpler and better to use the fixed column headings.
Cheers, Andrew
|
|
|