View Single Post
  #3  
Old November 30th, 2006, 08:22 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default SELECT Statement in a Report

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.