Connecting Tech Pros Worldwide Forums | Help | Site Map

Use Parameter Values in Variable Names

Takeadoe
Guest
 
Posts: n/a
#1: Sep 5 '06
Dear NG -

I was able to figure out how to use the IIF to compute the difference
in deer-vehicle accidents between years (2004 and 2005). My question
is, is it possible to use the results of the parameters in the variable
names or as variable names themselves? For instance, instead of [Y1]
and [Y2], is it possible to somehow use the returned value of YEAR1 and
YEAR2 (in this case, 2004 and 2005) either as new variable names or
parts thereof such as in a concatenation like Y&[YEAR1]?

ANY HELP AT ALL WOULD REALLY BE APPRECIATED.

MIKE

THIS IS MY QUERY BELOW

SELECT DeerVehicleAccidents.COUNTY, Sum(IIf([YEAR]=[YEAR1],[DVAS],0))
AS Y1, Sum(IIf([YEAR]=[YEAR2],[DVAS],0)) AS Y2, (([Y2]-[Y1])/[y1])*100
AS PercentChange
FROM DeerVehicleAccidents
GROUP BY DeerVehicleAccidents.COUNTY;


Rich P
Guest
 
Posts: n/a
#2: Sep 5 '06

re: Use Parameter Values in Variable Names


It sounds like you want to use an Alias for some field names - or result
values. You need to specify a little more detail what you need. For
example, in the query you included in your post - is this a working
query? Or is this a query you are trying to get to work?

If this is the query that you are trying to get to work - what is the
error message you get when you try to run it? You should also include
some samples of what your data looks like and what the resultset needs
to look like.

If the query you included is not the query that you are trying to get to
work, then you should include the query that you are trying to get to
work.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Takeadoe
Guest
 
Posts: n/a
#3: Sep 5 '06

re: Use Parameter Values in Variable Names


Rich,

Sorry about the shortage of detail. The query I included works
perfectly, from the standpoint that it gives me the percent change that
I'm looking for. I was just "fine tuning" with my question. If I
could include the year in the new variable name, it would just be a
little easier to keep track of what is being compared. Just tidying up
a bit, I suppose you could say.

Mike
Rich P wrote:
Quote:
It sounds like you want to use an Alias for some field names - or result
values. You need to specify a little more detail what you need. For
example, in the query you included in your post - is this a working
query? Or is this a query you are trying to get to work?
>
If this is the query that you are trying to get to work - what is the
error message you get when you try to run it? You should also include
some samples of what your data looks like and what the resultset needs
to look like.
>
If the query you included is not the query that you are trying to get to
work, then you should include the query that you are trying to get to
work.
>
Rich
>
*** Sent via Developersdex http://www.developersdex.com ***
Bri
Guest
 
Posts: n/a
#4: Sep 6 '06

re: Use Parameter Values in Variable Names


Takeadoe wrote:
Quote:
Rich,
>
Sorry about the shortage of detail. The query I included works
perfectly, from the standpoint that it gives me the percent change that
I'm looking for. I was just "fine tuning" with my question. If I
could include the year in the new variable name, it would just be a
little easier to keep track of what is being compared. Just tidying up
a bit, I suppose you could say.
>
Mike
No, AFAIK, you cannot use the results of a calculation in the alias
(what you are calling the variable name) for a field. You could
concatinate additional text to the results of the calculation, but the
alias name needs to be static.

--
Bri

Takeadoe
Guest
 
Posts: n/a
#5: Sep 6 '06

re: Use Parameter Values in Variable Names


Bri - two things THANKS and what is AFAIK?

Mike

Bri wrote:
Quote:
Takeadoe wrote:
Quote:
Rich,

Sorry about the shortage of detail. The query I included works
perfectly, from the standpoint that it gives me the percent change that
I'm looking for. I was just "fine tuning" with my question. If I
could include the year in the new variable name, it would just be a
little easier to keep track of what is being compared. Just tidying up
a bit, I suppose you could say.

Mike
>
No, AFAIK, you cannot use the results of a calculation in the alias
(what you are calling the variable name) for a field. You could
concatinate additional text to the results of the calculation, but the
alias name needs to be static.
>
--
Bri
Bri
Guest
 
Posts: n/a
#6: Sep 6 '06

re: Use Parameter Values in Variable Names


Takeadoe wrote:
Quote:
Bri - two things THANKS and what is AFAIK?
>
Mike
As Far As I Know

--
Bri

Closed Thread