R
RV Chris
I have created a Sales Comparison query that results in something like
the following:
(The first two columns compare last year with this year. The second 2
columns compare last month with the same month last year.)
CompanyName 2005 2006 200505 200605 Change
abc $777 $999 $22 $33 1.5
def $2929 $3999 $499 $899 1.8
It takes 3 queries to get here - 2 crosstabs and one select query that
puts the 2 crosstabs together, joined by the CompanyID.
1. qrySalesCompareAnnual (a crosstab)
2. qrySalesCompareMonthly (another crosstab)
3. qrySalesCompareAll (a select query that joins the two above)
It works beautiful, but it won't work next month, because the fields
200505 and 200605 won't exist. Next month, qrySalesCompareAll needs to
refer to 200506 and 200606.
Here's the SQL for qrySalesCompareAll
SELECT qrySalesCompareAnnual.*, qrySalesCompareMonthly.[200505],
qrySalesCompareMonthly.[200605], [200605]/[200505] AS Change
FROM qrySalesCompareAnnual INNER JOIN qrySalesCompareMonthly ON
qrySalesCompareAnnual.CoID = qrySalesCompareMonthly.CoID;
I can make a form which has a field for the current months, but I can't
figure out how to refer to that parameter as a field in my select
query. In my form, txtMonth = qrySalesCompareMonthly.[200605].
But, replacing qrySalesCompareMonthly.[200605] with
[Forms]![frmSalesComparison]![txtMonth] doesn't work.
Am I on the right track? Or is there another way to approach this.
Thanx!
Chris
the following:
(The first two columns compare last year with this year. The second 2
columns compare last month with the same month last year.)
CompanyName 2005 2006 200505 200605 Change
abc $777 $999 $22 $33 1.5
def $2929 $3999 $499 $899 1.8
It takes 3 queries to get here - 2 crosstabs and one select query that
puts the 2 crosstabs together, joined by the CompanyID.
1. qrySalesCompareAnnual (a crosstab)
2. qrySalesCompareMonthly (another crosstab)
3. qrySalesCompareAll (a select query that joins the two above)
It works beautiful, but it won't work next month, because the fields
200505 and 200605 won't exist. Next month, qrySalesCompareAll needs to
refer to 200506 and 200606.
Here's the SQL for qrySalesCompareAll
SELECT qrySalesCompareAnnual.*, qrySalesCompareMonthly.[200505],
qrySalesCompareMonthly.[200605], [200605]/[200505] AS Change
FROM qrySalesCompareAnnual INNER JOIN qrySalesCompareMonthly ON
qrySalesCompareAnnual.CoID = qrySalesCompareMonthly.CoID;
I can make a form which has a field for the current months, but I can't
figure out how to refer to that parameter as a field in my select
query. In my form, txtMonth = qrySalesCompareMonthly.[200605].
But, replacing qrySalesCompareMonthly.[200605] with
[Forms]![frmSalesComparison]![txtMonth] doesn't work.
Am I on the right track? Or is there another way to approach this.
Thanx!
Chris