Dates across top of report using only start and end dates

G

Guest

I need to see revenue by month for each of the months between the start and
end dates that a user enters. How do I get each month to show up across the
top of my report by just using the two dates entered?

For example, if the user wants to see projected revenue from next month
until Feb 2006, they should see June 2005, July 2005... Feb 2006 across the
top. In other words, I can't have fixed labels in my report. I need the
report to dynamically change the labels depending on the what the user
enters. I'm not sure how to go about it, or if there is a better way.

Help?
Thanks.
 
D

Duane Hookom

Below is a "canned" response for a crosstab report with month headings. I
would have a user enter only the ending date to get a report designed for a
specific number of months.

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 with menuing: Query|Parameter
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 with control sources of:
=DateAdd("m",0,Forms!frmA!txtE­ndDate)
=DateAdd("m",-1,Forms!frmA!txt­EndDate)
=DateAdd("m",-2,Forms!frmA!txt­EndDate)
=DateAdd("m",-3,Forms!frmA!txt­EndDate)
...
This solution requires no code and will run fairly quickly.
 
G

Guest

Thanks so much for this direction. I will give it a try - it makes sense
when you lay it out like that.
--
DEW


Duane Hookom said:
Below is a "canned" response for a crosstab report with month headings. I
would have a user enter only the ending date to get a report designed for a
specific number of months.

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 with menuing: Query|Parameter
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 with control sources of:
=DateAdd("m",0,Forms!frmA!txtE­ndDate)
=DateAdd("m",-1,Forms!frmA!txt­EndDate)
=DateAdd("m",-2,Forms!frmA!txt­EndDate)
=DateAdd("m",-3,Forms!frmA!txt­EndDate)
...
This solution requires no code and will run fairly quickly.


--
Duane Hookom
MS Access MVP
--

DEW said:
I need to see revenue by month for each of the months between the start and
end dates that a user enters. How do I get each month to show up across
the
top of my report by just using the two dates entered?

For example, if the user wants to see projected revenue from next month
until Feb 2006, they should see June 2005, July 2005... Feb 2006 across
the
top. In other words, I can't have fixed labels in my report. I need the
report to dynamically change the labels depending on the what the user
enters. I'm not sure how to go about it, or if there is a better way.

Help?
Thanks.
 

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