Cross Tab/Report Nightmare

D

DW

Has any one ever made a report based off a Cross Tab
query? If so, how did you handle changing row heading? For
example, I have a cross tab query that has Months as
Columns and Client names as rows. It is counting
the number of Accounts opening each month. I want the
column heading to change for a given date range.
For example, the user enters 1/1/2004 - 5/1/2004 into a
form and I want the column heading to reflect the months
in the range. Any suggetions on how to do this?

Thanks in Advance
DW
 
D

Duane Hookom

Not a nightmare if you are a little creative.
Try not to use "absolute" column headings for dates. You could possibly use
"relative" dates. For instance:
Form: frmA
Text Box: txtEndDate
Table: tblSales
Field: SaleDate
You want to show 12 months of sales in columns of a crosstab report.
Set the Query|Parameters
Forms!frmA!txtEndDate Date/Time

Use this expression for your Column Headings:
ColHead:"Mth" & DateDiff("m",[SaleDate],Forms!frmA!txtEndDate)
This will produce Mth0, Mth1, Mth2, Mth3,... where Mth0 is sales from the
same month as the ending date on your form.
Mth1 is the previous month etc.

Set your queries Column Headings property to:
Mth0, Mth1, Mth2, Mth3,.., Mth11

Build your report based on these "relative" months. If you need column
labels in your report, use text boxes:
=DateAdd("m",0,Forms!frmA!txtEndDate)
=DateAdd("m",-1,Forms!frmA!txtEndDate)
=DateAdd("m",-2,Forms!frmA!txtEndDate)
=DateAdd("m",-3,Forms!frmA!txtEndDate)
....
This solution requires no code and will run fairly quickly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top