RE: Dynamic fields

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Use these two queries ---
Al_X ---
SELECT Max(qryAnnualRenewalCost_1.FY) AS Max_FY
FROM qryAnnualRenewalCost_1;

TRANSFORM Sum(qryAnnualRenewalCost_1.SumOfCost) AS SubTotal
SELECT qryAnnualRenewalCost_1.Category
FROM qryAnnualRenewalCost_1, Al_X
WHERE (((qryAnnualRenewalCost_1.FY)=[Max_FY] Or
(qryAnnualRenewalCost_1.FY)=[Max_FY]-1))
GROUP BY qryAnnualRenewalCost_1.Category
PIVOT IIf([FY]=[Max_FY],"Current FY","Last FY");

--
KARL DEWEY
Build a little - Test a little


"Al" wrote:

The crosstab query:
TRANSFORM Sum(qryAnnualRenewalCost_1.SumOfCost) AS SubTotal
SELECT qryAnnualRenewalCost_1.Category
FROM qryAnnualRenewalCost_1
GROUP BY qryAnnualRenewalCost_1.Category
PIVOT qryAnnualRenewalCost_1.FY;
*********************************************
The query that I need built on the top of the crosstab is:
SELECT Sum(qryAnnualRenewalCost_2.[06]) AS Lastyr,
Sum(qryAnnualRenewalCost_2.[07]) AS Currentyr,
(([Currentyr]-[Lastyr])/[Lastyr]) AS Percent_Increase
FROM qryAnnualRenewalCost_2;
*********************************************
as you can see, I would rather have the columns named Currentyr and Lastyr
due to the fact that next year the crosstab would show 07 and 08 instead of
06 and 07. As it stands now, I would have to go in the design to change the
expression to match the Crosstab and what I am looking for is a dynamic way
to do the change automatically every year. I hope that clarifies the picture.
thanks
Al


"KARL DEWEY" wrote:

Yes, post your crosstab query SQL.
--
KARL DEWEY
Build a little - Test a little


"Al" wrote:

I have a crosstab query that show annual cost per category.as follow:

Category 06 07

a.Roads $324.00 $356.00
b.Buildings $277.00 $305.00

The crosstab always will show the current year and the last year. My problem
is that I want to build another query based on this crosstab, in doing so I
will be faced with a dilemma of having to change the field name next year
since they are going to be "07" and "08". Is there a way to have the field
name change automatically based on the year that we are in. this way the user
does not have to go in the query design to reslect the columns?
thanks
Al
.



Relevant Pages

  • RE: Crosstab - What am I doing wrong?
    ... "Deb" wrote: ... That helped with a couple of the queries, but I still need a Crosstab query ... "KARL DEWEY" wrote: ...
    (microsoft.public.access.queries)
  • RE: Crosstab - What am I doing wrong?
    ... Now I need to use that crosstab to build another query. ... It does pull everything, but it adds all of the unit costs for the ... "KARL DEWEY" wrote: ...
    (microsoft.public.access.queries)
  • RE: Crosstab - What am I doing wrong?
    ... That helped with a couple of the queries, but I still need a Crosstab query ... "KARL DEWEY" wrote: ...
    (microsoft.public.access.queries)
  • RE: Tranposing/Using rows/field values as column headings
    ... merging them back without exceeding the 255 field limit in a query. ... The Crosstab query below was able to get me this result: ... "KARL DEWEY" wrote: ... Actuals Acctgdata1 AcctgData2 AcctgData3 ...
    (microsoft.public.access.queries)
  • Re: Total of choice two
    ... use a crosstab, directly, to reach the result you seek: ... TRANSFORM Nz, 0) ... FROM myTable, PossibleChoices ... The query returns the number of occurrences of each choice, ...
    (microsoft.public.access.queries)