By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Use Parameter Values in Variable Names

P: n/a
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;

Sep 5 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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 ***
Sep 5 '06 #2

P: n/a
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:
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 ***
Sep 5 '06 #3

P: n/a
Bri
Takeadoe wrote:
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

Sep 5 '06 #4

P: n/a
Bri - two things THANKS and what is AFAIK?

Mike

Bri wrote:
Takeadoe wrote:
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
Sep 5 '06 #5

P: n/a
Bri
Takeadoe wrote:
Bri - two things THANKS and what is AFAIK?

Mike
As Far As I Know

--
Bri

Sep 6 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.