View Single Post
  #8  
Old December 1st, 2006, 08:18 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default SELECT Statement in a Report

You seem to be asking multiple questions at once. I would suggest that we
try to solve one question at a time.

1) Post the SQL of the crosstab query for specific advice on how you might
modify it to get just five years. If you want to vary the number of years
then we will hope that Duane Hookom is around and can point you to some
sample databases on how to do this.

2) Instead of hard coding the years, use relative column names like Year1,
Year2, Year3, Year4, and Year5. You can use code on a form or in a report
to change the captions on labels or the control source of unbound text
controls to show the year numbers.

3) If you have the start year and you are always going to have 5 years, you
don't need to ask for the end year. Plus if you are limiting the report to
5 years and the user enters 2005 to 2014 they are going to be confused when
they only get 2005 to 2009 data in the report.

Are you doing this on a form or are you doing this in a report?


"chickalina" wrote in message
...
John,
Also, I have a form that looks like thiswhich is only supposed to be a 5
year projection)

Country
Local
2007 2008 2009 2010 2011 Total
Idea 5 5 5 5 5 25

State
Idea 4 4 4 4 4 16

The yearly totals are taken from a Crosstab Query, but the years are hard
coded.
If I want 2012 included, I have to go back into the query and add that
column. How can this be done automatically?

Because I want to create a pop up form for the report where they can put a
start and end date so the report only shows the 5 year window. How do I
set
up the report fields?

OR, is this too involved?

P.S. this is also the same report where I'm putting the SELECT statement
in
the footer.

"chickalina" wrote:

John,
Thanks for the help... I'm going rename Value to QtrValue or something
like
that... but for now, the code still does not work. Might that be because
of
the placement on the report? It's in the footer now to give apply this
equation to each section.
I've tried with the brackets and without.
Thanks.

"John Spencer" wrote:

It looks as if you have ther brackets incorrectly placed.

SELECT [tbl_Ideas_Bank].[IdeaID]
, [tbl_Ideas_Bank].[BenefitType]
, [tbl_Quarter].[QtrEndDate]
, [tbl_Quarter].[Value]
FROM [tbl_Ideas_Bank], [ tbl_Quarter]
WHERE ((([tbl_Ideas_Bank].[BenefitType])="ETR & Cash") AND
((tbl_Quarter.QtrEndDate) Between #1/1/2007# And #12/31/2007#)));

And since you really don't need the brackets becuase your table and
field
names contain no spaces. That could be rewritten as
SELECT tbl_Ideas_Bank.IdeaID
, tbl_Ideas_Bank.BenefitType
, tbl_Quarter.QtrEndDate
, tbl_Quarter.Value
FROM tbl_Ideas_Bank, tbl_Quarter
WHERE tbl_Ideas_Bank.BenefitType="ETR & Cash" AND
tbl_Quarter.QtrEndDate Between #1/1/2007# And #12/31/2007#

I would be wary of using "Value" as a field name, since it is a
reserved
word in Access, but you are probably OK in the query. Elsewhere the
use of
the word Value could cause naming conflicts since most controls have a
value
property.

"chickalina" wrote in message
...
What's wrong with this code? It keeps giving me the ?Error message,
and
when
I try to run the report, it says there's a problem. It runs in the
query
though.

SELECT [tbl_Ideas_Bank.IdeaID]![ tbl_Ideas_Bank.BenefitType],
[tbl_Quarter.QtrEndDate],[ tbl_Quarter.Value]
FROM [tbl_Ideas_Bank],[ tbl_Quarter]
WHERE (((tbl_Ideas_Bank.BenefitType)="ETR & Cash") AND
((tbl_Quarter.QtrEndDate) Between #1/1/2007# And #12/31/2007#)));

Thanks.